06.02.2015, 15:00
(
Последний раз редактировалось HazardouS; 06.02.2015 в 16:38.
)
I'll write a short tutorial for you.
EDIT: global variables
pawn Код:
// SetTimer - useful for functions without parameters
// SetTimerEx - useful for functions with parameters
//global variables
new OneSecondTimer;
new ParamFunctionTimer;
public OnGameModeInit()
{
OneSecondTimer = SetTimer("OneSecTick", 1000, true); // 1000 miliseconds equals 1 second, true means it will repeat every second. Set that to false to call "OneSecTick" only once, 1 second after timer creation
}
public OnPlayerConnect(playerid)
{
// [..]
ParamFunctionTimer = SetTimerEx("TwoMinutesCheck", 120000, false, "d", playerid);
// [..]
}
forward OneSecTick();
public OneSecTick()
{
//one second passed, do something here. Let's kill the timer:
KillTimer(OneSecondTimer); //even if the repeat was set to true, now we stopped it so it doesn't matter
}
forward TwoMinutesCheck(playerid);
public TwoMinutesCheck(playerid)
{
SendClientMessage(playerid, -1, "Two minutes passed since you connected.");
//timer repeat was set to false, so it killed itself when it called the function
return 1;
}