新版本
COOP應該可以用啦
複製內容到剪貼板
代碼:
#include <sourcemod>
#include <sdktools>
#define FCVAR_FLAGS FCVAR_PLUGIN|FCVAR_NOTIFY
#define IsValidClient(%1) (1 <= %1 <= MaxClients && IsClientInGame(%1))
new Handle:timerr[MAXPLAYERS+1] = { INVALID_HANDLE,...};
new count[MAXPLAYERS+1];
new Handle:sec = INVALID_HANDLE;
new Handle:hurt = INVALID_HANDLE;
new bool:ontimer=false;
public Plugin:myinfo =
{
name = "**侮辱成份** timer",
author = "david43/Apple_W",
description = "**侮辱成份** timer",
version = "0.0.0.2",
url = "N/A",
}
public OnPluginStart()
{
player_left_checkpoint
HookEvent("player_left_checkpoint",Event_player_left_checkpoint);
HookEvent("round_start",Event_round_start);
HookEvent("player_left_start_area",round_start);
HookEvent("player_entered_checkpoint",round_end);
HookEvent("round_end",Event_round_end);
HookEvent("player_use",Event_Player_Use);
sec = CreateConVar("l4d2_timer_sec","500","幾秒後開始扣血", FCVAR_FLAGS);
hurt = CreateConVar("l4d2_timer_hurt","5","招幾多血", FCVAR_FLAGS);
}
public OnMapStart()
{
ontimer=false;
}
public Action:Event_player_left_checkpoint(Handle:event, const String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));
timerr[client]=CreateTimer(1.0,counts,client,TIMER_REPEAT)
count[client]=2;
}
public Action:Event_Player_Use(Handle:event, const String:name[], bool:dontBroadcast)
{
if(!ontimer)
{
ontimer=true;
new client = GetClientOfUserId(GetEventInt(event, "userid"));
new Entity = GetEventInt(event, "targetid");
new String:entname[MAXLENGTH];
GetEdictClassname(Entity, entname, sizeof(entname))
if(StrEqual(entname, "prop_door_rotating_checkpoint"))
{
for( new i = 1; i < GetMaxClients(); i++ )
{
if (IsValidClient(i))
{
if (GetClientTeam(i)==2)
{
count[i]=GetConVarInt(sec);
timerr[i]=CreateTimer(1.0,counts,i,TIMER_REPEAT)
}
}
}
}
}
}
public Action:Event_round_start(Handle:event, const String:name[], bool:dontBroadcast)
{
for( new i = 1; i < GetMaxClients(); i++ )
{
if(timerr[i]!=INVALID_HANDLE)
{
KillTimer(timerr[i])
timerr[i]=INVALID_HANDLE;
count[i]=GetConVarInt(sec);
}
}
}
public Action:round_start(Handle:event, const String:name[], bool:dontBroadcast)
{
/*for( new i = 1; i < GetMaxClients(); i++ )
{
if (IsValidClient(i))
{
if (GetClientTeam(i)==2)
{
count[i]=GetConVarInt(sec);
timerr[i]=CreateTimer(1.0,counts,i,TIMER_REPEAT)
}
}
}*/
}
public Action:counts(Handle:timer,any:i)
{
if(count[i]<=0)
{
SlapPlayer(i,GetConVarInt(hurt));
}
count[i]-=1;
PrintHintText(i,"你還有%d秒",count[i]);
}
public Action:round_end(Handle:event, const String:name[], bool:dontBroadcast)
{
new client =GetClientOfUserId(GetEventInt(event, "userid"));
if (IsValidClient(client))
{
if (GetClientTeam(client)==2 && timerr[client]!=INVALID_HANDLE)
{
PrintToChat(client,"你在%d秒到達安全室",count[client]);
KillTimer(timerr[client])
timerr[client]=INVALID_HANDLE;
count[client]=GetConVarInt(sec);
}
}
}
public Action:Event_round_end(Handle:event, const String:name[], bool:dontBroadcast)
{
for( new i = 1; i < GetMaxClients(); i++ )
{
if(timerr[i]!=INVALID_HANDLE)
{
KillTimer(timerr[i])
timerr[i]=INVALID_HANDLE;
count[i]=GetConVarInt(sec);
}
}
}