• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

24h reward system.

N

NoFontNL

Guest
Hi all, how would I get a 24 hour reward system?
I know what I should do. Save current time als savedTime. If newtime is 24h bigger than savedTime then canCollect=true. But I have trouble with saving time and calculating the new time.
I can't get it right. Any help is appreciated.
#1 | How would I save the current time? (day, hour, minute, second);
- I had in mind with current_day, current_hour, current_minute, current_second.
#2 | How can I check if the new time is 24h bigger than the savedTime?
- I think I could do this with savedDay - current_day;
savedHour - current_hour etc. but I think it'll get pretty hard because of it's for example now 13.00h and the savedHour is 9.00h then it'll end up with -4.00h.
------------------------------------------------------------------------------------------------------
Thanks in advance!
 

CloseRange

Member
how much googling did you do before posting this? look here
Code:
date_current_datetime();
that will get the current time. Save this.
later when you load that datetime call this:
Code:
if date_hour_span(date1, date2) >= 24;
where date1 is the the the value that you loaded and date2 is the current time of you calling the function
 
N

NoFontNL

Guest
how much googling did you do before posting this? look here
Code:
date_current_datetime();
that will get the current time. Save this.
later when you load that datetime call this:
Code:
if date_hour_span(date1, date2) >= 24;
where date1 is the the the value that you loaded and date2 is the current time of you calling the function
I tried that but got an error:
Check compile window for any further information. Only that. And I couldn't find anything in the compile window. Only random letters with an equal sign. Like this:

BFK=0 etc.

I'll try again.
 

TsukaYuriko

☄️
Forum Staff
Moderator
Semicolons ( ; ) have no right to exist at the end of an if statement unless your motivation for placing them there is the production of a compile time error.
 

TsukaYuriko

☄️
Forum Staff
Moderator
Please do not post images of code. For further information, I suggest reading this topic: How to Q&A

You are using date_current_datetime like a variable. It is a function. (Or maybe you just forgot to add parentheses?)
 
N

NoFontNL

Guest
Code:
 if date_hour_span(temptime, date_current_datetime()) >= 24 {
        file_delete("time.ini");
    }
I get an error Wrong number of arguments in date_hour_span, but there are 2 in there. Just as asked for.

And further I need more help with these errors. I cannot work them out.
 
N

nkostic97vr

Guest
Also on line 8 you don't have parentheses for date_current_datetime. If you still get errors, post updated code and list of errors.
 
N

NoFontNL

Guest
Also on line 8 you don't have parentheses for date_current_datetime. If you still get errors, post updated code and list of errors.
I think that made the job. But now, I'm drawing the time until I can spin again but it says 23.88. Musn't be the '.88' minutes?
How can I convert the the numbers after the decimal into minutes? So not the full number. And in seconds. So like H:23 M:52 S:48
 
Top