Thread: Timer Issue
View Single Post
Lubricant Jam
AlliedModders Donor
Join Date: Oct 2016
Old 12-29-2018 , 06:41   Re: Timer Issue
Reply With Quote #14

Quote:
Originally Posted by Ilusion9 View Post
PHP Code:

Handle hTimer
;

public 
void OnMapEnd()
{
    
delete hTimer;
}

public 
Action Event_RoundEnd(Event event, const char[] namebool dontBroadcast)
{
    
delete hTimer;
}

public 
Action Event_RoundStart(Event event, const char[] namebool dontBroadcast)
{
    
g_iCountdown 30;
    
    
hTimer CreateTimer(1.0EndZoneCheck_TIMER_REPEAT);
}

public 
Action EndZoneCheck(Handle timerany data)
{
    for (
int i 1<= MaxClientsi++)
    {
        if (
IsClientInGame(i) && IsPlayerAlive(i) && coursetimer_InEndZone(i))
        {
            
EmitSoundToAll("training/countdown.wav"iSNDCHAN_VOICESNDLEVEL_RAIDSIREN);
            
PrintToChatAll("[SM] \x07%N \x02has reached the end!"i);
            
PrintToChatAll("[SM] \x0330 seconds remaining to complete the map.");
            
            
ForcePlayerSuicide(i);
            
            
hTimer CreateTimer(1.0Timer_CountdownGetClientUserId(i), TIMER_REPEAT);
            return 
Plugin_Stop;
        }
    }
    
    return 
Plugin_Continue;
}

public 
Action Timer_Countdown(Handle timerany data)
{
    
int client GetClientOfUserId(data);

    if (
g_iCountdown && 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<= 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!
Lubricant Jam is offline