02.03.2012, 04:05
I found a better way that actually works using a PlayerCount variable. (duh)
pawn Code:
new Timer,PlayerCount;
public OnGameModeInit()
{
PlayerCount = 0; // Whenever the server is executed, player count will be zero
return 1;
}
public OnPlayerConnect(playerid)
{
Timer = SetTimer("YourFunction",5000,true); // Repeats a timer of 5 seconds
PlayerCount++; // Whenever a player connects player count will inscrease by 1.
return 1;
}
public OnPlayerDisconnect(playerid)
{
PlayerCount--; // When a player disconnects player count will decrease by 1.
return 1;
}
forward YourFunction();
public YourFunction() // Every 5 seconds....
{
// Object Code here
if(PlayerCount == 0) // If no players are on then....
{
KillTimer(Timer); // kill the timer.
}
return 1;
}

