pInfo[playerid][VIPDays]+ getdate()
`VIPDays`=%d
pInfo[playerid][VIPDays] -30 > getdate())
{
SendClientMessage(playerid,COLOR_GREEN,"Your VIP has expired! Thank you for donating!");
pInfo[playerid][VIP] = 0;
}
This is how im saving it into the sql |
"CREATE EVENT `removevip_%i` ON SCHEDULE EVERY 1 MONTH STARTS NOW() DO UPDATE `users` SET `playerVIP`=0 WHERE `uniqeID`=%i", playerData[toplayerid][uID], playerData[toplayerid][uID] // (uniqueid)
pInfo[playerid][VIPDays] = (getdate() + (86400 * 31)); // Giving the player 31 days of VIP
if(pInfo[playerid][VIPDays] < getdate()) { // The player's VIP has expired, do what you want here.
}
(86400 * 31);
Okay now I have those 2 milion seconds, and I compare it with getdate?
|
pInfo[playerid][VIPDays] = (getdate() + (86400 * 31)); // This is how you give the player 31 days.
if(pInfo[playerid][VIPDays] < getdate()) { // This is how you check if the VIP timestamp was in the past, or is in the future
}
Also how could I format it to tell player how many days he has left?
|
if(pInfo[playerid][VIPDays] < getdate())
And how could I print out time left for it if its even possible?
|
EDIT: Okay sorry I havent seen that, but the code you gave me for example wont work. Whenever I connect it says that it expired.
PHP код:
|
// [ DEVELOPMENT GAMEMODE ]
// INCLUDES:
#include <a_samp>
#include <zcmd>
// DEFINES:
// FUNCTIONS:
#define plural_singular(%0,%1,%2) ((%0) == 1) ? ((#%1)) : ((#%2))
// MAIN:
main()
{
print("Development Mode: expire_time.amx");
}
// CALLBACKS:
public OnGameModeInit()
{
return 1;
}
public OnGameModeExit()
{
return 1;
}
// COMMANDS:
CMD:timeleft(playerid, params[])
{
if((gettime() - (PLACE THE TIMESTAMP LIST ELEMENT HERE)) < (PLACE THE DAY LIST ELEMENT HERE))
{
new string[144], second = (PLACE THE TIMESTAMP LIST ELEMENT HERE) - gettime() + (PLACE THE DAY LIST ELEMENT HERE), minute, hour, day, week, month, year;
format(string, sizeof(string), "Time left: %s.", ConvertToTime(second, minute, hour, day, week, month, year));
SendClientMessage(playerid, -1, string);
}
else
{
SendClientMessage(playerid, -1, "30 days have passed.");
}
return 1;
}
CMD:timeover(playerid, params[])
{
if((gettime() - (PLACE THE TIMESTAMP LIST ELEMENT HERE)) < (PLACE THE DAY LIST ELEMENT HERE))
{
SendClientMessage(playerid, -1, "30 days hasn't passed yet.");
return cmd_timeleft(playerid, "");
}
else
{
SendClientMessage(playerid, -1, "30 days have passed.");
}
return 1;
}
// FUNCTIONS:
stock ConvertToTime(&second, &minute = -1, &hour = -1, &day = -1, &week = -1, &month = -1, &year = -1)
{
#define seconds_in_year 31536000
#define seconds_in_month 2628000
#define seconds_in_week 604800
#define seconds_in_day 86400
#define seconds_in_hour 3600
#define seconds_in_minute 60
#define convert_seconds(%1) %1 = second / seconds_in_%1; second %= seconds_in_%1
new string[128];
if(year != -1 && (second / seconds_in_year))
{
convert_seconds(year); convert_seconds(month); convert_seconds(week); convert_seconds(day); convert_seconds(hour); convert_seconds(minute);
format(string, sizeof(string), "%d %s, %d %s, %d %s, %d %s, %d %s, %d %s, and %d %s", year, plural_singular(year, "year", "years"), month, plural_singular(month, "month", "months"), \
week, plural_singular(week, "week", "weeks"), day, plural_singular(day, "day", "days"), hour, plural_singular(hour, "hour", "hours"), minute, plural_singular(minute, "minute", "minutes"), \
second, plural_singular(second, "second", "seconds"));
return string;
}
if(month != -1 && (second / seconds_in_month))
{
year = 0; convert_seconds(month); convert_seconds(week); convert_seconds(day); convert_seconds(hour); convert_seconds(minute);
format(string, sizeof(string), "%d %s, %d %s, %d %s, %d %s, %d %s, and %d %s", month, plural_singular(month, "month", "months"), week, plural_singular(week, "week", "weeks"), \
day, plural_singular(day, "day", "days"), hour, plural_singular(hour, "hour", "hours"), minute, plural_singular(minute, "minute", "minutes"), second, plural_singular(second, "second", "seconds"));
return string;
}
if(week != -1 && (second / seconds_in_week))
{
year = 0, month = 0; convert_seconds(week); convert_seconds(day); convert_seconds(hour); convert_seconds(minute);
format(string, sizeof(string), "%d %s, %d %s, %d %s, %d %s, and %d %s", week, plural_singular(week, "week", "weeks"), day, plural_singular(day, "day", "days"), \
hour, plural_singular(hour, "hour", "hours"), minute, plural_singular(minute, "minute", "minutes"), second, plural_singular(second, "second", "seconds"));
return string;
}
if(day != -1 && (second / seconds_in_day))
{
year = 0, month = 0, week = 0; convert_seconds(day); convert_seconds(hour); convert_seconds(minute);
format(string, sizeof(string), "%d %s, %d %s, %d %s, and %d %s", day, plural_singular(day, "day", "days"), hour, plural_singular(hour, "hour", "hours"), \
minute, plural_singular(minute, "minute", "minutes"), second, plural_singular(second, "second", "seconds"));
return string;
}
if(hour != -1 && (second / seconds_in_hour))
{
year = 0, month = 0, week = 0, day = 0; convert_seconds(hour); convert_seconds(minute);
format(string, sizeof(string), "%d %s, %d %s, and %d %s", hour, plural_singular(hour, "hour", "hours"), minute, plural_singular(minute, "minute", "minutes"), \
second, plural_singular(second, "second", "seconds"));
return string;
}
if(minute != -1 && (second / seconds_in_minute))
{
year = 0, month = 0, week = 0, day = 0, hour = 0; convert_seconds(minute);
format(string, sizeof(string), "%d %s, and %d %s", minute, plural_singular(minute, "minute", "minutes"), second, plural_singular(second, "second", "seconds"));
return string;
}
year = 0, month = 0, week = 0, day = 0, hour = 0, minute = 0;
format(string, sizeof(string), "%d %s", second, plural_singular(second, "second", "seconds"));
return string;
}