14.09.2018, 16:08
Quote:
That is, I must use three times "for (new i = 0, j = GetPlayerPoolSize (); i <= j; i ++)"?
Please, I need a quick help. |
That way only one of those loops will ever be executed at once (so technically it's just one loop per execution).
Even if it were 3, those aren't very complex loops so I don't see how there would be any issues.
PHP код:
public DerbyCountdown()
{
if(DI[STATUS] != DERBY_WAIT) return KillTimer(DI[COUNTDOWN_TIMER]);
if(DI[PLAYERS] <= 0) return CloseDerby();
if(DI[PLAYERS] == 1)
{
DI[COUNTDOWN_COUNTER] = DERBY_TIME_COUNTDOWN + 1;
for(new playerid = 0, j = GetPlayerPoolSize(); playerid <= j; playerid++)
{
if(IsPlayerConnected(playerid))
{
if(Player[playerid][Mode] == GAME_DERBY)
{
GameTextForPlayer(playerid, "~g~Waiting for players", 500, 3);
}
}
}
return 1;
}
DI[COUNTDOWN_COUNTER] --;
if(DI[COUNTDOWN_COUNTER] > 0)
{
for(new playerid = 0, j = GetPlayerPoolSize(); playerid <= j; playerid++)
{
if(IsPlayerConnected(playerid))
{
if(Player[playerid][Mode] == GAME_DERBY)
{
new str[10]; format(str, 10, "~r~%d_minutes_to_start", DI[COUNTDOWN_COUNTER]);
GameTextForPlayer(playerid, str, 1000, 3);
}
}
}
}
else
{
KillTimer(DI[COUNTDOWN_TIMER]);
if(DI[PLAYERS] == 0) return CloseDerby();
else if(DI[PLAYERS] == 1)
{
for(new playerid = 0, j = GetPlayerPoolSize(); playerid <= j; playerid++)
{
if(IsPlayerConnected(playerid))
{
if(Player[playerid][Mode] == GAME_DERBY)
{
GameTextForPlayer(playerid, "~g~Waiting for players", 500, 3);
}
}
}
DI[COUNTDOWN_COUNTER] = DERBY_TIME_COUNTDOWN + 1;
KillTimer(DI[COUNTDOWN_TIMER]);
DI[COUNTDOWN_TIMER] = SetTimer("DerbyCountdown", 900, true);
}
else StartDerby();
}
return 1;
}