|
Use gettime(); it will give you the current timestamp based off your computer's time.
Use it to add timestamp + (60 * 60 * 24) to the VIP variable, when you check the timestamp again and it's greater than the set value, end their VIP membership. If you don't know PAWN, learn it or pay someone to do stuff like this for you. |
new VIPTime[MAX_PLAYERS];
public OnPlayerConnect(playerid) {
VIPTime[playerid] = 0;
// Load VIPTime from a file.
if(VIPTime[playerid] != 0) {
// Give them membership.
}
return 1;
}
public OnPlayerDisconnect(playerid, reason) {
// Save the VIPTime variable.
}
public OnPlayerUpdate(playerid) {
new Timestamp = gettime();
if(Timestamp >= VIPTime[playerid]) {
// Cancel their membership.
VIPTime[playerid] = 0;
}
return 1;
}
stock AddMembershipForADay(playerid) {
if(! IsPlayerConnected(playerid)) {
return false;
}
if(VIPTime[playerid] == 0) { // new member
VIPTime[playerid] += gettime();
// Give them membership.
}
VIPTime[playerid] += (60 * 60 * 24);
return true;
}
stock DisplayMembershipRemaining(playerid) {
new Format[100] = "No membership!";
if(! IsPlayerConnected(playerid)) {
return '\0';
}
if(VIPTime[playerid] == 0) {
return Format;
}
new timestamp = VIPTime[playerid] - gettime();
new year = 0, day = 0, month = 0, hour = 0, mins = 0, sec = 0;
new days_of_month[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
while(timestamp > 31622400){
timestamp -= 31536000;
if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) {
timestamp -= 86400;
}
year++;
}
if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) {
days_of_month[1] = 29;
}
else {
days_of_month[1] = 28;
}
while(timestamp > 86400) {
timestamp -= 86400;
day++;
if(day==days_of_month[month]) {
day = 0;
month++;
}
}
while(timestamp > 60){
timestamp -= 60;
mins++;
if(mins == 60) {
mins=0;
hour++;
}
}
sec = timestamp;
format(Format, 31, "VIP Time Remaining: %02d/%02d/%d %02d:%02d:%02d", day+1, month+1, year, hour, mins, sec);
return Format;
}