SA-MP Forums Archive
KillTimerEx - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: KillTimerEx (/showthread.php?tid=166479)



KillTimerEx - Mike Garber - 08.08.2010

I'd really need such function, Is there any such function, or a stock function somewhere?


Re: KillTimerEx - (.Aztec); - 08.08.2010

Just do:


At the top:

pawn Code:
new timer;
Near your timer:

pawn Code:
timer = SetTimerEx("Blah", 1000, 1, "i", playerid);
Kill Timer:

pawn Code:
KillTimer(timer);
Should work, I don't know for sure though.


Re: KillTimerEx - Mike Garber - 08.08.2010

Sorry, but your answer did not solve my problem.
(I'm not a n00b, i could figure the above by myself, If I needed that).

If you know what SetTimerEx does, I'd like the same options for KillTimer.

Which is, kill the timer for a specific player ID only.


Re: KillTimerEx - (.Aztec); - 08.08.2010

Quote:
Originally Posted by Mike Garber
View Post
Sorry, but your answer did not solve my problem.
(I'm not a n00b, i could figure the above by myself, If I needed that).

If you know what SetTimerEx does, I'd like the same options for KillTimer.

Which is, kill the timer for a specific player ID only.
Well, my knowledge is flawed then. I thought it would kill it, but I was wrong, I spose.


Re: KillTimerEx - ivex - 08.08.2010

yes it is so you do like this

new timer[MAX_PLAYERS];

timer[playerid] = SetTimerEx("fnc", 2000, true, "i", playerid);

KillTimer(timer[playerid]);

that will kill timer for just specific ID !


Re: KillTimerEx - Mike Garber - 08.08.2010

Quote:
Originally Posted by (.Aztec);
View Post
Well, my knowledge is flawed then. I thought it would kill it, but I was wrong, I spose.
It would kill It, but It is for several players. So If It the timer was used by someone else at the same time, It would stop It for them too, which would cause problems.


Re: KillTimerEx - JaTochNietDan - 08.08.2010

Quote:
Originally Posted by Mike Garber
View Post
It would kill It, but It is for several players. So If It the timer was used by someone else at the same time, It would stop It for them too, which would cause problems.
You would need to create a seperate timer for each player and store it in an array variable with the corrosponding playerid. Like ivex explained.


Re: KillTimerEx - Mike Garber - 08.08.2010

Quote:
Originally Posted by ivex
View Post
yes it is so you do like this

new timer[MAX_PLAYERS];

timer[playerid] = SetTimerEx("fnc", 2000, true, "i", playerid);

KillTimer(timer[playerid]);

that will kill timer for just specific ID !
Yeah I thought of that,
but hey, I just thought of something else (Yes I always seem to find solutions to my problems when I ask for It..)

It's made like this;

pawn Code:
forward Timer(playerid);

SetTimerEx("Timer",milliseconds,0,"i",playerid);
So would KillTimer(Timer(playerid)); stop it for that player only?
It compiles fine so, I just wondered.


Re: KillTimerEx - [XST]O_x - 08.08.2010

I don't believe KillTimer is working with only-forwarded timers,you need to create a separated variable for each timer.
Like JaTochNietDan said,use ivex's code.


Re: KillTimerEx - JaTochNietDan - 08.08.2010

Quote:
Originally Posted by Mike Garber
View Post
Yeah I thought of that,
but hey, I just thought of something else (Yes I always seem to find solutions to my problems when I ask for It..)

It's made like this;

pawn Code:
forward Timer(playerid);

SetTimerEx("Timer",milliseconds,0,"i",playerid);
So would KillTimer(Timer(playerid)); stop it for that player only?
It compiles fine so, I just wondered.
No. KillTimer will try to kill the ID of the timer, what's happening with

pawn Code:
KillTimer(Timer(playerid));
Is that it's simply trying to kill the return value of Timer(playerid); as the ID of the timer. So no, you need to use a variable to store the timer ID in for later killing.