In the first place, excuse me for bumping this thread! As I'm working with y_timers right now, let me answer this question for the next generation:
PHP код:
/* Set all cells to -1 */
new Timer:myTimer[MAX_PLAYERS] = {Timer:-1, ...};
/* Start the timer */
CMD:mycommand(playerid, params[])
{
myTimer[playerid] = repeat MyOwnFunction(playerid);
/* MyOwnFunction will be called 1 second after we type the
command, due the delay parameter from timer, that's how it works. */
return 1;
}
/* Declare MyOwnFunction as a timer */
timer MyOwnFunction[1000](playerid)
{
printf("The player who started timer %d has the ID %d.", _:myTimer[playerid], playerid);
// This function will print the same message every second.
}
/* Stop the timer */
COMMAND:stoptimer(playerid, params[])
{
if(myTimer[playerid] != Timer:-1)
{
stop myTimer[playerid];
myTimer[playerid] = Timer:-1;
}
else
{
// The timer isn't running.
}
return 1;
}