30.01.2016, 16:31
Good tutorial but use timestamps...
Its 1000x easier and faster.
Its 1000x easier and faster.
PHP код:
CMD:setvip(playerid,params[]) {
new sPlayer,Time;
if(sscanf(params,"ui",sPlayer,Time)) return Msg(playerid,COLOR_RED,"Usage: /setvip [playerid] [days]");
if(Time <= 0) return Msg(playerid,COLOR_RED,"Time cannot be equal to 0 or go bellow it");
if(sPlayer == INVALID_PLAYER_ID) return Msg(playerid,COLOR_RED,"Invalid player");
new finalcalc = (Time*3600)+gettime(); /* 3600 seconds per day + currenttime, it will give us until when they have to be VIP*/
PlayerInfo[playerid][VIPTime] = finalcalc; //store the variable
PlayerInfo[playerid][VIPLevel] = 1; //optional, set player VIP level or something
return true;
}
public OnPlayerConnect(playerid) {
//load the PlayerInfo[playerid][VIPTime]
new currentTime = gettime();
if(currentTime >= PlayerInfo[playerid][VIPTime]) { //if current time is bigger than the time they should be VIP for.
Msg(playerid,COLOR_RED,"Your VIP has expired. Please consider purchasing more");
PlayerInfo[playerid][VIPLevel] = 0;
}
return true;
}