V.I.P Expire
#1

Hello guys, I have made a VIP system, I made it to give the player one month of vip when i /setvip him. I have already tested it. It said: expires in blablablabla 59 seconds then 56 seconds. Now, how to remove the player's vip lvl when it expires? Help please.

pInfo[playerid][VIPExpire] < Stores the expiry time. (Gettime + one month)
Reply
#2

I mean "how to remove his vip lvl when the vip expires" = How to check if the gettime is bigger than his VIPExpire, and if it is bigger = pInfo[playerid][VIP] = 0.
Reply
#3

Something like this can work.
PHP код:
funktion(playerid)
{
    if(
/*get vip expire time*/ getdate)
    {
        
remove his vip level
    
}
    else
    {
        new 
string[100], format(stringsizeof(string), "Your VIP level will expire on %d"vip level variable);
        
SendClientMessage(playerid, -1string);
    }

Reply
#4

Quote:
Originally Posted by ALiScripter
Посмотреть сообщение
Something like this can work.
PHP код:
funktion(playerid)
{
    if(
/*get vip expire time*/ getdate)
    {
        
remove his vip level
    
}
    else
    {
        new 
string[100], format(stringsizeof(string), "Your VIP level will expire on %d"vip level variable);
        
SendClientMessage(playerid, -1string);
    }

My question isnt how to make this "funktion", it is where to put this function? In a repeating timer or what
Reply
#5

Use the function when a player connects or use a timer of 10 minutes thats a public or a global timer and loop through all the players and execute the function.
Reply
#6

PHP код:
new Expire[MAX_PLAYERS];
CMD:setvip(playeridparams)
{
    new 
targetid;
    
Expire[targetid] = gettime()+2592000;//30days(seconds)
}
SaveFuction(playerid)
{
    
//save Expire
}
LoadFunction(playerid)
{
    
//load Expire
}
RegisterFunction(playerid)
{
    
//Expire[playerid] = 0;
}
OnPlayerUpdate(playerid)
{
    if(
Expire[playerid] < gettime()) pInfo[playerid][VIP] = 0;

Reply
#7

Shinja, do you even know OnPlayerUpdate is called frequently and will cause lag, I am sure he wants to send a message to client when he removes the vip level, and if he sends the message in the OPU, it will spam the chat.
Reply
#8

Quote:
Originally Posted by ALiScripter
Посмотреть сообщение
Shinja, do you even know OnPlayerUpdate is called frequently and will cause lag, I am sure he wants to send a message to client when he removes the vip level, and if he sends the message in the OPU, it will spam the chat.
Ah, yes my bad. Just gave a example, he can set a timer for it or anything instead of OnPlayerUpdate
Reply
#9

Seconds convert to:
Quote:

#define Minutes(%0) %0 * 60
#define Hours(%0) %0 * 3600
#define Days(%0) %0 * 86400
#define Weeks(%0) %0 * 604800
#define Month(%0) %0 * 2592000

Use a timer, not this callback!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)