25.07.2015, 00:50
A unix timestamp is a number, the amount of seconds it has been since January 1, 1970. Right now, that's approximately at 1437784996 seconds - though it doesn't account for timezones, it accounts for the time of the server it's being checked from (the server will generate a unix timestamp by calculating how many seconds it has been since 1970).
So now you have this number, you have a rough guide of where we are at in time, we can add to that time or subtract from it for measurement purposes. We can add a day to the current timestamp (1437784996) which is (1437784996+86400), that number will now represent 01:43 on the 26th of July instead of 01:43 (a day ahead) on the 25th of July (the current time, well, close enough, I forgot when I started writing this post).
If you set your VIPDays variable to the current unix timestamp then add 31 days (86400 * 31; that is 1 day in seconds multiplied by 31, number of days in a month) you can check if that timestamp is in the future or the past. So at this point we would write this code:
Remember, we get the current unix timestamp, then add 31 days (in seconds) to that value. Now we can check if that date has passed when the player logs in:
So you're checking if the value is in the future or the past, fairly simple?
So now you have this number, you have a rough guide of where we are at in time, we can add to that time or subtract from it for measurement purposes. We can add a day to the current timestamp (1437784996) which is (1437784996+86400), that number will now represent 01:43 on the 26th of July instead of 01:43 (a day ahead) on the 25th of July (the current time, well, close enough, I forgot when I started writing this post).
If you set your VIPDays variable to the current unix timestamp then add 31 days (86400 * 31; that is 1 day in seconds multiplied by 31, number of days in a month) you can check if that timestamp is in the future or the past. So at this point we would write this code:
pawn Код:
pInfo[playerid][VIPDays] = (getdate() + (86400 * 31)); // Giving the player 31 days of VIP
pawn Код:
if(pInfo[playerid][VIPDays] < getdate()) { // The player's VIP has expired, do what you want here.
}