Player timers
#1

I need to make a system for 'player-timers'. I was disappointed that this wasn't included in y_timers, as I think it's a very 'useful' thing to have. If you're reading this ******, perhaps you could add it? It needs to kill timers when a player disconnects, basically. I was thinking

SetPlayerTimer(playerid, interval, bool:repeat, format[], {Float,_}:...); // Returns the SetTimerEx return value (timerid)

but I would struggle with the {Float,_}:... part. I've never used getarg before. Is there another way to do it? Obviously it just needs an array to store the timer ID in, but that needs to be reset when the timer is called if it's not a repeating timer.

The only solution I can think of is something like

pawn Код:
SetPlayerTimer(playerid, interval(-1 if repeating), SetTimerEx(...));
and run another timer alongside the actual one to reset the variable. I really don't want to do this though.

Any solutions?
Reply
#2

Yeah but I'd rather have a 'simplfied' system instead of having to create an array for every single timer :/

You'd also have to track every timer. If it gets killed with KillTimer you have to hook that and set the varaible to -1, if it gets called and it's not a repeating timer you have to set it to -1 other wise you end up with conflicting IDs. Unless timer slots never get re-used..? I should test that. Unlikely though.


EDIT: Hmm, once a timer expires or is killed, the 'ID' is never used again. I didn't know that.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)