SA-MP Forums Archive
Timer question - 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: Timer question (/showthread.php?tid=558618)



Timer question - quark - 18.01.2015

Hey guys. Is better to make less timers and more code on the timers or different timers with less code? Thanks in advance


Re: Timer question - CalvinC - 18.01.2015

I'm using a global timer of 1 second, that loops through all players and checks for different things.
Etc. if they are in a taxi with a taximeter ticking, i increase the "taximetertick" with
pawn Код:
TaximeterTick[i]++;
And then it checks for other stuff too, as prison time, and decreases the prisontime by 1.
pawn Код:
PrisonTime[i]--;
Not sure if this is the best way though.


Re: Timer question - Misiur - 18.01.2015

More timers with less code. You can kill off unnecessarily running ones, you don't have to build complex if clauses to check which ones should execute. Also the code is much clearer, and you can store your timers closer to logic they are related to. Check out y_timers for really clean code with best coding practices kept (player timers and tasks are super cool).


Re: Timer question - quark - 18.01.2015

Quote:
Originally Posted by CalvinC
Посмотреть сообщение
I'm using a global timer of 1 second, that loops through all players and checks for different things.
Etc. if they are in a taxi with a taximeter ticking, i increase the "taximetertick" with
pawn Код:
TaximeterTick[i]++;
And then it checks for other stuff too, as prison time, and decreases the prisontime by 1.
pawn Код:
PrisonTime[i]--;
Not sure if this is the best way though.
I'm using it like this, but it has some delay, dunno why