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



Which is faster? (Timers) - CrucixTM - 12.10.2010

20 timers that checks if the player is in range of one point each, or 1 timer that checks if the player is in range of one of 20 points?

I'm making a script where the player will gradually loose HP in some areas, and I need to know what method to use.


Re: Which is faster? (Timers) - Rachael - 12.10.2010

In my opinion the speed would be similar for both, you could check the efficiency by using
pawn Код:
tickcount(); // time.inc
For neatness and simplicity I would pick the latter of the two options.


Re: Which is faster? (Timers) - General Abe - 12.10.2010

One timer. Why have nineteen more player loops and timers ticking away than you need?


Re: Which is faster? (Timers) - Rachael - 12.10.2010

This is a good point, I didn't think of that.


Re: Which is faster? (Timers) - Mauzen - 12.10.2010

A point FOR multiple timers: If you have only one timer, you will have to loop through all players, checking if they are connected. But if you create a timer per player on connection you wont have to check if he is connected every time.

But i think one timer is still faster. If you use foreach it is for sure.