V.I.P Expire - 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: V.I.P Expire (
/showthread.php?tid=614238)
V.I.P Expire -
Ahmed21 - 06.08.2016
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)
Re: V.I.P Expire -
Ahmed21 - 06.08.2016
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.
Re: V.I.P Expire -
Logic_ - 06.08.2016
Something like this can work.
PHP код:
funktion(playerid)
{
if(/*get vip expire time*/ < getdate)
{
remove his vip level
}
else
{
new string[100], format(string, sizeof(string), "Your VIP level will expire on %d", vip level variable);
SendClientMessage(playerid, -1, string);
}
}
Re: V.I.P Expire -
Ahmed21 - 06.08.2016
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(string, sizeof(string), "Your VIP level will expire on %d", vip level variable);
SendClientMessage(playerid, -1, string);
}
}
|
My question isnt how to make this "funktion", it is where to put this function? In a repeating timer or what
Re: V.I.P Expire -
Logic_ - 06.08.2016
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.
Re: V.I.P Expire -
Shinja - 06.08.2016
PHP код:
new Expire[MAX_PLAYERS];
CMD:setvip(playerid, params)
{
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;
}
Re: V.I.P Expire -
Logic_ - 06.08.2016
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.
Re: V.I.P Expire -
Shinja - 06.08.2016
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
Re: V.I.P Expire -
G4M30V3R - 06.08.2016
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!