Posts: 303
Threads: 68
Joined: Dec 2008
Reputation:
0
Hey, is there a way to use "gettime" and "getdate", then save them in a string...
Then later compare them. and check for the difference.
So if its todays date...
23/04/2009 time = 16:03:17 (approx)
then save that, so then it can be compared later when needed..
So take the above date and time... check it against the current date and time, then get the difference..
To make it easier, i'd like to first compare the dates, if they match then compare the times...
If they dont match just clear the saved date and time..
Posts: 74
Threads: 3
Joined: Apr 2008
Reputation:
0
Why do you want to save them in a string...?! And not as integers?
Posts: 2,593
Threads: 38
Joined: Aug 2007
Reputation:
0
I think he's considering a temporary ban function or something.
second=second1-second2;
if(second<0){second+=60;minute1-=1;}
minute=minute1-minute2;
if(minute<0){minute+=60;hour1-=1;}
hour=hour1-hour2;
if(hour<0){hour+=24;day1-=1;}
day=day1-day2;
if(day<0){day+=30;month1-1;} //the 30 depends on the month could be 30, 31, 28, or 29
month=month1-month2;
if(month<0){month+=12;year1-=1;}
year=year1-year2;
Then year,month,day,hour, and minute are set to the difference of time 1 and time 2
Posts: 303
Threads: 68
Joined: Dec 2008
Reputation:
0
I dont really want to use too many "if"s
I need to compare them, and check weather or not 30minutes have gone by or not..
If the player logs on within 30mins of leaving the server, the data from the file will be loaded.
If they login after 30mins of leaving the server the file will be deleted.
So i need to check if its been 30mins from the player leaving to reconnecting...
Posts: 1,293
Threads: 6
Joined: Jul 2008
Reputation:
0
Assuming the server is on the whole time, use gettickcount(), and then work out what 30 minutes is in milliseconds.
Posts: 1,293
Threads: 6
Joined: Jul 2008
Reputation:
0
Or read the previous response and use gettickcount...
Posts: 303
Threads: 68
Joined: Dec 2008
Reputation:
0
I Like the idea of converting it into one number...
The only thing with that is. If the player leaves at 11:45pm and they login again at 12:05am then the date changes...
So im not sure how i can make it work accurately