Timers: How do they work?
#5

Timers are just...timers.
You set it, you let it work, then boom, you get results...
for example, I want a timer and loops through the whole online players in my server, and then check for a specific aspect in them (like if they are cops, terrorists, admin etc..)
or, I can just set a timer to send a timed message, reminders, MOTD's etc...

how timers work?
It's seriously and insanly easy!
For instance, I want a timer that goes through the entire online players, and checks if they are VIP's...
So, here's what I do
pawn Код:
public OnGameModeInit()
{
    SetTimer("VIPChekcer", 1000, true); // "1000" represents the time, "true" means the timer will repeat itself after 100 millisecs (1 second)
    return 1;
}
So this basicly sets a timer in my script...now to edit "VIPChecker" content to find VIP's... (or do anything I like)
pawn Код:
forward VIPChecker();
Just place that on top of your script, it basicly "forwards" a public function...now to make this public function, just do this, anywhere. (as long as it is AFTER the line where we forward'd the public function)
pawn Код:
public VIPChecker()
{
    for(new i = 0; i < MAX_PLAYERS; i++) // loops through the whole online players.
    {
        if(PlayerInfo[i][pVIP] == 1) // checks if the players (represented by "i") are VIP's or not.
        {
            // if they are I'll send them a message.
        }
    }
}
Reply


Messages In This Thread
Timers: How do they work? - by waxhunter - 04.06.2012, 21:15
Re: Timers: How do they work? - by leonardo1434 - 04.06.2012, 21:19
Re: Timers: How do they work? - by milanosie - 04.06.2012, 21:20
Re: Timers: How do they work? - by waxhunter - 04.06.2012, 21:23
Re: Timers: How do they work? - by Sandiel - 04.06.2012, 21:23
Re: Timers: How do they work? - by milanosie - 04.06.2012, 21:26
Re: Timers: How do they work? - by ricardo178 - 04.06.2012, 22:02
Re: Timers: How do they work? - by Edward156 - 04.06.2012, 23:08
Re: Timers: How do they work? - by waxhunter - 04.06.2012, 23:21
Re: Timers: How do they work? - by waxhunter - 04.06.2012, 23:47

Forum Jump:


Users browsing this thread: 1 Guest(s)