[Question] gettime() without paramters.
#1

Hey
I have question about gettime().
I'm creating VIP System, with expiration, and I used the gettime() with mktime.
If I'll do gettime() and mktime like that:
Quote:

VIP[playerid][Timestamp] = gettime() + mktime(0, 0, 0, 4, 0, 0);

I did it for 4 days, if I'll connect at the same time after 4 days it will works? or before the hour that I bought the VIP?

I mean, for an example, I did /buyvip at 16:00 and it will activate it for 4 days, if I'll connect
after 4 days on 16:00 it will work or before?


mktime code: (dutils.inc)
Quote:

stock mktime(hour,minute,second,day,month,year) {
new timestamp2;

timestamp2 = second + (minute * 60) + (hour * 3600);

new days_of_month[12];

if ( ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0) ) {
days_of_month = {31,29,31,30,31,30,31,31,30,31,30,31}; // Schaltjahr
} else {
days_of_month = {31,28,31,30,31,30,31,31,30,31,30,31}; // keins
}
new days_this_year = 0;
days_this_year = day;
if(month > 1) { // No January Calculation, because its always the 0 past months
for(new i=0; i<month-1;i++) {
days_this_year += days_of_month[i];
}
}
timestamp2 += days_this_year * 86400;

for(new j=1970;j<year;j++) {
timestamp2 += 31536000;
if ( ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0) ) timestamp2 += 86400; // Schaltjahr + 1 Tag
}

return timestamp2;
}

Reply
#2

Yeah it should but actually you dont need mktime for that
You know that gettime() returns the unix timestamp in seconds than just add 4 days in seconds

pawn Код:
VIP[playerid][Timestamp] = gettime() + (4 * 24 * 60 * 60); // 4 days * 24 hours * 60 minutes * 60 seconds
Reply
#3

Thank you (+REP)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)