KillTimerEx
#1

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

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.
Reply
#3

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.
Reply
#4

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.
Reply
#5

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 !
Reply
#6

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.
Reply
#7

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.
Reply
#8

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.
Reply
#9

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.
Reply
#10

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)