01.03.2012, 17:06
If you kill a timer when it is set to repeat will it continue to repeat or does that kill it completely?
new
Timer,
TimerCount = 0; // Sets the timer count to zero.
CMD:start(playerid,params[])
{
Timer = SetTimer("YourFunction",5000,true); // Repeats a timer of 5 seconds
return 1;
}
forward YourFunction();
public YourFunction() // Every 5 seconds....
{
TimerCount++; // Timer count is added. The Timer will repeat itself until it matched the below if statement.
if(TimerCount == 5) // If the timer has been repeated five times.
{
KillTimer(Timer); // Then kill the timer.
return 1;
}
}
new Timer;
forward YourFunction();
public YourFunction() // Every 5 seconds....
{
// Object Code here
for(new i = 0; i < MAX_PLAYERS; i++) // Loops through all the players
{
if(!IsPlayerConnected(i)) // If IsPlayerConnected for all players returns false.
{
KillTimer(Timer); // Then kill the timer.
}
}
return 1;
}
public OnPlayerConnect(playerid)
{
Timer = SetTimer("YourFunction",5000,true); // Repeats a timer of 5 seconds
return 1;
}
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;
}