Stopping a timer using y_timers. - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Stopping a timer using y_timers. (
/showthread.php?tid=407440)
Stopping a timer using y_timers. -
Shetch - 13.01.2013
I can easily start a timer, it works fine, but I can't stop it for some reason?
Код:
COMMAND:timer(playerid, params[])
{
SendClientMessage(playerid, COLOR_GREEN, "1 Second timer launched!");
repeat PlayerData(playerid);
return 1;
}
COMMAND:killtimer(playerid, params[])
{
SendClientMessage(playerid, COLOR_GREEN, "1 Second timer stopped!");
new Timer:x = repeat PlayerData(playerid);
stop x;
return 1;
}
timer PlayerData[1000](playerid)
{
SendClientMessage(playerid, COLOR_YELLOW, "ONE SECOND HAS PASSED!");
}
Re: Stopping a timer using y_timers. -
Scenario - 13.01.2013
You need to name the timer when you first create it. Here's an example:
You'll need to of course add a new timer variable at the top of your script to make it global. So... new Timer:OneSecTimer[MAX_PLAYERS];
This is going to have to be under the first command: OneSecTimer[playerid] = repeat PlayerData(playerid);
Then in the killtimer command, you'll just need to have: stop OneSecTimer[playerid];
See how that works for you. If you have any questions, please ask!