Always check
#1

Hello , how can i make a loop which checks every 10 mins if a player has vip .
I'm trying to create a temporary vip system and i don't know how to make the server check if the vip time is up
Reply
#2

Use a global timer + for(new...), then into the timer stock, insert your 'check' functions.
Reply
#3

I'd recommend saving the actual tick (GetTickCount()) of the moment when the player got VIP, then you know exactly when the time is up. A timer will produce slight offsets with each call, since they are never precise.

Saving the tick for said moment:

Код:
PlayerGotVIPTick[playerid] = GetTickCount();
Inside the timer function:

Код:
new curTick = GetTickCount();

for(new i = 0; i < MAX_PLAYERS; i ++)
{
    if(!IsPlayerConnected(i) || IsPlayerNPC(i)) continue; // Skips non-connected players & NPCs

    if(curTick - PlayerGotVIPTick[i] > 600000) // 10 mins passed, but you have to check if that player actually has VIP!
    {
        // ...
    }
}
You might want to replace the 600000 ms by a value that represents the duration of VIP.

Quote:
Originally Posted by Harty
Посмотреть сообщение
Use a global timer + for(new...), then into the timer stock, insert your 'check' functions.
Btw a timer cannot be local nor a stock, it can only call a public function.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)