Local & Global timers
#1

I wonder,
When use a global timer, and when use a local timer?

What's a local timer? What's a global timer?
Reply
#2

Someone explain me this?
Reply
#3

..maybe no good scripters online now..i m also waiting for help :P
Reply
#4

...there exist no local timers...but i think i know what you mean.

Look you can run a timer for every player like:

PHP код:
//Under OnPlayerConnect:
SetTimerEx("PlayerTimer",999,1,"i",playerid); 
This timer would run for every player...

A global timer is sth like this:

PHP код:
//Under OnGameModeInit
SetTimer("ForAll",999,1);
forward ForAll();
public 
ForAll()
{
    for(new 
ii<MAX_PLAYERSi++)
    {
         
//here the code
    
}

So you see..the global timer handels all players in one timer..so you dont need 500 timers..only 1
Reply
#5

Just remember that if you run too many timers, it's going to cause some optimization problems. Don't have a global timer that runs every 5 seconds and does a MAX_PLAYERS or MAX_VEHICLES loop. And if for some stupid reason you ARE doing that- use y_iterate (foreach) and y_timers. I use y_timers on my own mode and while switching to that as opposed to SetTimer() may be daunting at first- don't fret; it's a lot better!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)