One timer or loop?
#1

Alright so Ive got a question, what behaves better
SetTimerEx (bound to player) or SetTimer (using to loop thru players) ?

Lets say for example im using Health check, well simply I want a timer to run every few seconds to check players health and if they are above like 99 they will be banned, now my question remains, is it better to set 1 timer (SetTimerEx) or use SetTimer and use foreach with it to check all players that have possibly over 99 health?

My issue is that SetTimerEx that would loop every second could slow down the server a bit with some player base
Now the SetTimer with 1 second for example loop, im not sure

What would be better?

Note: Im using health hack check for example, im not really using a timer for it. Its basically just a simple codding question I need some explanations regarding it.
Reply
#2

Hello!

Use the SetTimer with a loop it is better because if you use SetTimerEx you can have (the maximum!) 500 timers at the same moment, and this is too much. Well, use SetTimer with a loop and do it like this:
That's the best way for a good performance:
PHP код:
public Timer()
{
    for(new 
i,j=GetPlayerPoolSize();i<=j;i++)
    {
        if(!
IsPlayerConnected(i) || IsPlayerNPC(i))continue;
    }
    return 
1;

Reply
#3

Quote:
Originally Posted by Mencent
Посмотреть сообщение
Hello!

Use the SetTimer with a loop it is better because if you use SetTimerEx you can have (the maximum!) 500 timers at the same moment, and this is too much. Well, use SetTimer with a loop and do it like this:
That's the best way for a good performance:
PHP код:
public Timer()
{
    for(new 
i,j=GetPlayerPoolSize();i<=j;i++)
    {
        if(!
IsPlayerConnected(i) || IsPlayerNPC(i))continue;
    }
    return 
1;

Sorry, but no.

OT: This has been discussed already.
https://sampforum.blast.hk/showthread.php?tid=575349
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)