08.03.2019, 00:46
Are you using any plugin or include related to timers? Are you running any code often which takes a lot of time to be executed? What OS are you running your server on?
Your code seems okay, I've tried to improve it a little bit tho. Feel free to take a look:
Your code seems okay, I've tried to improve it a little bit tho. Feel free to take a look:
PHP код:
Start_Map[DM] = SetTimerEx("StartMap", 1000, true, "d", DM);
forward StartMap(mode);
public StartMap(mode)
{
/*
Two cells are okay for this array since the countdown
displays just a character + EOS (for example 3 + \0).
The EOS (\0) is used to close the string, and it takes one cell.
*/
new string[2];
switch(mode)
{
case DM:
{
Countdown[DM]--;
for(new i = 0, t = GetPlayerPoolSize(); i <= t; i++)
{
/*
This code skips the ID if the player is not
connected or if his pMode is not set to DM.
*/
if(!IsPlayerConnected(i) || pMode[i] != DM)
{
continue;
}
/*
The code below is executed for connected
players who have pMode set to DM.
*/
if(Countdown[DM] > 0)
{
format(string, sizeof(string), "%d", Countdown[DM]);
GameTextForPlayer(i, string, 1000, 4);
}
else
{
KillTimer(Vehicle_Freeze[DM]);
KillTimer(Start_Map[DM]);
Countdown[DM] = 4;
GameTextForPlayer(i, "Go!", 1000, 4);
TogglePlayerControllable(i, true);
}
}
}
}
return 1;
}