temp vip help??? - 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: temp vip help??? (
/showthread.php?tid=548557)
temp vip help??? -
JawsPlus - 30.11.2014
How to make VIP expire in real time
This is code
Код:
COMMAND:setvip(playerid,params[])
{
if(!CmdLevelCheck(playerid,"setmoney")) return CmdLevelError(playerid,"setmoney");
{
new targetid,Level ,file[256];
if(sscanf(params, "ud", targetid, Level)) return SendClientMessage(playerid, COLOR_RED,"[USAGE]:{FFFFFF}/setvip [playerid] [level 1/3]");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid,COLOR_RED, "[ERROR]:{FFFFFF}This player is offline");
if(Level > 3) return SendClientMessage(playerid, COLOR_RED, "[ERROR]:{fFFFFF}Max VIP level is 3");
if(PInfo[targetid][pVIP] == Level)return SendClientMessage(playerid, COLOR_RED,"[ERROR]:{FFFFFF}This player is already with this vip level.");
{
new name[50],string[390],str[390],tname[50];
GetPlayerName(playerid,name,sizeof(name));
GetPlayerName(targetid,tname,sizeof(tname));
format(file, sizeof(file), PATH, name);
dini_IntSet(file, "VIP",PInfo[playerid][pVIP]);
PInfo[targetid][pVIP] = Level;
format(str, sizeof(str),"{FF02A7}[ADMIN]:{FFFFFF}%s had set %s VIP level to %d.",name,tname,Level);
SendClientMessageToAll(0xFF9900AA,str);
}
}
return 1;
}
Re: temp vip help??? -
AnthonyTimmers - 30.11.2014
Use a timer.
Код:
SetTimer("UnVIP", 60000, false, "i", targetid); // 60.000 milliseconds = 1 minute, change it to whatever you want.
forward UnVIP(playerid);
public UnVIP(playerid)
{
// Make player not a VIP anymore
}
If you are saving the VIP level somewhere, for example on log-out, make sure that it doesn't save a temporary VIP level.
+Rep if I helped you
Re: temp vip help??? -
Raweresh - 30.11.2014
Change:
Код:
new targetid,Level ,time,file[256];
if(sscanf(params, "udd", targetid, Level, time))
That
time is vip time in days.
Declare global variable:
Код:
new PlayerVipTime[MAX_PLAYERS];
Give vip:
Код:
PlayerVipTime[targetid] = gettime() + 86400 * time;
Save:
Код:
dini_IntSet(file, "VIPTime",PlayerVipTime[playerid]);
Check if player still have vip:
Код:
if(PlayerVipTime[playerid] >= gettime())
{
//Have vip
}
else
{
//If player is not vip anymore
}
Check how long the player will have vip:
Код:
PlayerVipTime[playerid] -= gettime(); //It's time in seconds;