|
Member
|
12-29-2018
, 12:16
Re: Timer Issue
|
#23
|
Quote:
Originally Posted by XiLuo
TIMER_FLAG_NO_MAPCHANGE flag is that will not allow timer pass next map.And the flag TIMER_REPEAT for timer if you not kill it until the next map will kill
So to avoid timer repeat more,you can try this code
PHP Code:
public Action Event_RoundStart(Handle event, const char[] name, bool dontBroadcast) { g_iCompleted = 0; g_iCountdown = 30; //if last round the timer is not over , we kill it and create new if(EndZoneTimer != INVALID_HANDLE) { KillTimer(EndZoneTimer); EndZoneTimer = INVALID_HANDLE; } if(CountdownTimer!=INVALID_HANDLE) { KillTimer(CountdownTimer); CountdownTimer = INVALID_HANDLE; } EndZoneTimer = CreateTimer(1.0, EndZoneCheck, INVALID_HANDLE, TIMER_REPEAT); }
public Action EndZoneCheck(Handle timer, int userid) { for (int client = 1; client <= MaxClients; ++client) { if (IsClientInGame(client) && coursetimer_InEndZone(client) && IsPlayerAlive(client)) { if (g_iCompleted == 0) { EmitSoundToAll("training/countdown.wav", client, SNDCHAN_VOICE, SNDLEVEL_RAIDSIREN); PrintToChatAll("[SM] \x07%N \x02has reached the end!", client); PrintToChatAll("[SM] \x0330 seconds remaining to complete the map."); ForcePlayerSuicide(client); CountdownTimer = CreateTimer(1.0, Timer_Countdown, GetClientUserId(client), TIMER_REPEAT); g_iCompleted++; //It's time to kill this timer and set it INVALID_HANDLE KillTimer(timer);//KillTimer(EndZoneTimer); EndZoneTimer = INVALID_HANDLE; } } } }
public Action Timer_Countdown(Handle timer, int userid) { int client = GetClientOfUserId(userid);
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); } } // round over we must kill this timer now KillTimer(timer);//KillTimer(CountdownTimer); CountdownTimer = INVALID_HANDLE; } else PrintToChatAll("[SM] \x03%d seconds remaining to complete the map.", g_iCountdown);
g_iCountdown--; } }
if there's something wrong please correct me,thanks.
Excuse my poor English,thanks again.
|
Please try it again, If roundstart works well,the timer will be one
Last edited by XiLuo; 12-30-2018 at 01:02.
|
|
|
|