Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: R4L on Thu 15/12/2005 23:53:53

Title: Better Code (GetTime() get current year)?
Post by: R4L on Thu 15/12/2005 23:53:53
I have this code for a little cheat in my game:

in repeatedly_execute:
GetRawTime();
if ((GetTime(5) == 3) && (GetTime(4) == 4)){
Display("Cheats");
Display("Actually, there are no cheats! Keep looking!");


It works because it checks if the user's computer clock is set to March 4, but because it does not check the year I won't accept this. The GetTime(); function does not have years. Can someone help me with this?
Title: Re: Better Code?
Post by: Ashen on Fri 16/12/2005 00:28:07
Actually, GetTime() does have years - it's GetTime(6);.

I can't remember off-hand whether it returns 2 or 4 digit (i.e. "05" or "2005"), but I think it's 4.

(And, of course, if you're using 2.7+, you should really use the DateTime.Day/Month/Year/etc properties.)
Title: Re: Better Code (GetTime() get current year)?
Post by: Gilbert on Fri 16/12/2005 02:34:40
Actually AGS can only return the year correctly for V2.7+, this feature was added back in V2.62 but it never worked.
Title: Re: Better Code (GetTime() get current year)?
Post by: Ashen on Fri 16/12/2005 11:10:03
That's odd, I'm sure it worked in AoK before we upgraded to 2.7 ... Let me check ...

Ah, yes, it seems like it returns the years since 1900 (so "105", not "2005"). Would this be good enough for your purposes, Rap4Life42o?

The alternative, I guess, is to get the Raw time, divide it by the number of seconds in a year (31,557,600) and add that to 1970 (when the RawTime 'clock' started).
Title: Re: Better Code (GetTime() get current year)?
Post by: Gilbert on Fri 16/12/2005 11:16:10
Right, the millenium bug kicked in when you use V2.62, though of course it can be compensated, still basically it's not working properly.