SA-MP Forums Archive
Always check - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Always check (/showthread.php?tid=603311)



Always check - Ax3l123 - 21.03.2016

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


Respuesta: Always check - Harty - 21.03.2016

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


Re: Respuesta: Always check - NaS - 21.03.2016

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.