|
AlliedModders Donor
|
12-29-2018
, 06:41
Re: Timer Issue
|
#14
|
Quote:
Originally Posted by Ilusion9
PHP Code:
Handle hTimer;
public void OnMapEnd()
{
delete hTimer;
}
public Action Event_RoundEnd(Event event, const char[] name, bool dontBroadcast)
{
delete hTimer;
}
public Action Event_RoundStart(Event event, const char[] name, bool dontBroadcast)
{
g_iCountdown = 30;
hTimer = CreateTimer(1.0, EndZoneCheck, _, TIMER_REPEAT);
}
public Action EndZoneCheck(Handle timer, any data)
{
for (int i = 1; i <= MaxClients; i++)
{
if (IsClientInGame(i) && IsPlayerAlive(i) && coursetimer_InEndZone(i))
{
EmitSoundToAll("training/countdown.wav", i, SNDCHAN_VOICE, SNDLEVEL_RAIDSIREN);
PrintToChatAll("[SM] \x07%N \x02has reached the end!", i);
PrintToChatAll("[SM] \x0330 seconds remaining to complete the map.");
ForcePlayerSuicide(i);
hTimer = CreateTimer(1.0, Timer_Countdown, GetClientUserId(i), TIMER_REPEAT);
return Plugin_Stop;
}
}
return Plugin_Continue;
}
public Action Timer_Countdown(Handle timer, any data)
{
int client = GetClientOfUserId(data);
if (g_iCountdown > 0 && IsClientInGame(client))
{
if ((g_iCountdown == 20) || (g_iCountdown == 10) || (g_iCountdown == 5) || (g_iCountdown < 4))
{
if (g_iCountdown == 1)
{
PrintToChatAll("[SM] \x03%d second remaining to complete the map.", g_iCountdown);
for (int i = 1; i <= MaxClients; ++i)
{
if(IsClientInGame(i) && IsPlayerAlive(i) && GetClientTeam(i) > 1)
{
ForcePlayerSuicide(i);
}
}
hTimer = null;
return Plugin_Stop;
}
}
else
{
PrintToChatAll("[SM] \x03%d seconds remaining to complete the map.", g_iCountdown);
}
g_iCountdown--;
}
return Plugin_Continue;
}
|
This fixed my issue, thanks a bunch!
|
|
|
|