04.06.2012, 21:23
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
So this basicly sets a timer in my script...now to edit "VIPChecker" content to find VIP's... (or do anything I like)
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)
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;
}
pawn Код:
forward VIPChecker();
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.
}
}
}