Jump to content
  • 0

set variable


Feefty

Question


  • Group:  Members
  • Topic Count:  47
  • Topics Per Day:  0.01
  • Content Count:  175
  • Reputation:   14
  • Joined:  11/21/11
  • Last Seen:  

how do you set a local account variable every midnight.

thanks.

Link to comment
Share on other sites

16 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  44
  • Reputation:   48
  • Joined:  11/19/11
  • Last Seen:  

OnClock<hour><minute>:

OnMinute<minute>:

OnHour<hour>:

On<weekday><hour><minute>:

OnDay<month><day>:

This will execute when the server clock hits the specified date or time. Hours and minutes are given in military time. ('0105' will mean 01:05 AM). Weekdays are Sun,Mon,Tue,Wed,Thu,Fri,Sat. Months are 01 to 12, days are 01 to 31. Remember the zero. :)

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  205
  • Reputation:   19
  • Joined:  10/12/12
  • Last Seen:  

OnClock<hour><minute>:

OnMinute<minute>:

OnHour<hour>:

On<weekday><hour><minute>:

OnDay<month><day>:

This will execute when the server clock hits the specified date or time. Hours and minutes are given in military time. ('0105' will mean 01:05 AM). Weekdays are Sun,Mon,Tue,Wed,Thu,Fri,Sat. Months are 01 to 12, days are 01 to 31. Remember the zero. :)

Yeah, but I believe he wanted to set on all accounts, that variable at midnight.

You'll need to use a query_sql into an OnMinute00 event label.

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  47
  • Topics Per Day:  0.01
  • Content Count:  175
  • Reputation:   14
  • Joined:  11/21/11
  • Last Seen:  

OnClock<hour><minute>:

OnMinute<minute>:

OnHour<hour>:

On<weekday><hour><minute>:

OnDay<month><day>:

This will execute when the server clock hits the specified date or time. Hours and minutes are given in military time. ('0105' will mean 01:05 AM). Weekdays are Sun,Mon,Tue,Wed,Thu,Fri,Sat. Months are 01 to 12, days are 01 to 31. Remember the zero. :)

Yeah, but I believe he wanted to set on all accounts, that variable at midnight.

You'll need to use a query_sql into an OnMinute00 event label.

i guess there's no way of doing this without using sql.

Thanks.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  16
  • Topics Per Day:  0.00
  • Content Count:  737
  • Reputation:   216
  • Joined:  11/29/11
  • Last Seen:  

There always a way but sql would be faster here yeah.

btw do you really need all account ?, if so I wonder why you bother setting it as account variable instead server if it's for all...

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  205
  • Reputation:   19
  • Joined:  10/12/12
  • Last Seen:  

i guess there's no way of doing this without using sql.

Thanks.

There is still a way, but It's pretty odd and requires a lot of memory and heap.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  47
  • Topics Per Day:  0.01
  • Content Count:  175
  • Reputation:   14
  • Joined:  11/21/11
  • Last Seen:  

There always a way but sql would be faster here yeah.

btw do you really need all account ?, if so I wonder why you bother setting it as account variable instead server if it's for all...

i'm using it for my daily quest.

i got it to work.

Thanks anyway.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  44
  • Reputation:   48
  • Joined:  11/19/11
  • Last Seen:  

You could always model the data differently.

Eg. Lets say you have a quest you want players to do only once every day.

You could:

a. Check for a variable every time they do the quest. If it is set then they've done it already and don't let them do the quest. Reset every variable at midnight.

OR

b. Set a variable with the date everytime they do the quest. Then check using that variable that it's been at least 1 day before they do the quest.(no messy super reset using sql)

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

b. Set a variable with the date everytime they do the quest. Then check using that variable that it's been at least 1 day before they do the quest.(no messy super reset using sql)

yay for this <3

http://www.eathena.ws/board/index.php?showtopic=243105

http://www.eathena.ws/board/index.php?showtopic=243358

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  205
  • Reputation:   19
  • Joined:  10/12/12
  • Last Seen:  

b. Set a variable with the date everytime they do the quest. Then check using that variable that it's been at least 1 day before they do the quest.(no messy super reset using sql)

Fully agree, but I was just answering what he wanted to know.

how do you set a local account variable every midnight.

He didn't ask for quest variables, or how to solve particular problems about that, he just asked how to set a local account variable every midnight.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  16
  • Topics Per Day:  0.00
  • Content Count:  737
  • Reputation:   216
  • Joined:  11/29/11
  • Last Seen:  

Yes but in this case Toasty awnser ain't too far. not the main subject but there otherway to do daily check quest instead assigning all account.

For quick exemple of what he said.

OnHour00: //each day
set $daily_quest,gettime(8); //save new day
end;

(on quest part)
OnStart: //supposed entry of npc
if(#daily_quest >= $daily_quest) {
  mes "Sorry one char of this account already did this daily quest today";
}
....

OnEnd: //suppose end of npc
set #daily_quest,gettime(8); //mark day when quest was finished.
end;

This approch is valid for 1year, assign only variable for player who actually do the quest, (so no useless data), and is ofc faster.

But yeah beside looping and having headeach for offline char, sql would be the way to go.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  205
  • Reputation:   19
  • Joined:  10/12/12
  • Last Seen:  

Yes but in this case Toasty awnser ain't too far. not the main subject but there otherway to do daily check quest instead assigning all account.

For quick exemple of what he said.

OnHour00: //each day
set $daily_quest,gettime(8); //save new day
end;

(on quest part)
OnStart: //supposed entry of npc
if(#daily_quest >= $daily_quest) {
  mes "Sorry one char of this account already did this daily quest today";
}
....

OnEnd: //suppose end of npc
set #daily_quest,gettime(8); //mark day when quest was finished.
end;

This approch is valid for 1year, assign only variable for player who actually do the quest, (so no useless data), and is ofc faster.

But yeah beside looping and having headeach for offline char, sql would be the way to go.

Again, I totally agree.

But the point is that, who said it's for a quest?

What if I want the #var to be X exactly as midnight?

Until he tells further details, that's his request. How to set (to an X value) #var of all characters at midnight.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  379
  • Reputation:   304
  • Joined:  11/10/11
  • Last Seen:  

I wrote a function in the past called "autocleanvar" to add a delay timer to a variable to auto-delete it automatically.

It's another approach, more complex, but possible too :P

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  44
  • Reputation:   48
  • Joined:  11/19/11
  • Last Seen:  

@ryokem

Feefty said it was for their daily quest script. Of course I have no way to be sure but its perfectly reasonable for me to guess what they are using it for and to provide suggestions based upon that. There's no reason you should be shutting down someone's suggestions like this. It just locks out 'out of the box' suggestions which doesn't help anyone at all.

There's not too many instances where you really do need to set all of a certain # var at a certain time. Like you can't even use the var if the player is offline.

@lighta

Using gettimetick(2) / 86400 will give a 'day tick' using epoch time. Will work till like 2036. I can't remember if it uses UTC time or server time though...

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  16
  • Topics Per Day:  0.00
  • Content Count:  737
  • Reputation:   216
  • Joined:  11/29/11
  • Last Seen:  

@Toasty

Ye I know but it's a cleaner exemple like this; better to demonstrate imo. But ain't really a perfect exemple cause we don't even need to set the server variable in that case.

Anyway if he don't want to deal with tick he could always use YYYYMMDD or YYYYDDD.

@Ryokem

I understand that you want to keep the subject as the author state, many time I've been on some irc to ask one things and get remark about thing you don't care / was done for the exemple etc...

But it's support section, I believe we have to point out that is compception ain't perfect and that he may want to reconsider it.

And if we were really upset about what we ask we all awnsered sql but none give a proper exemple wich is not perfect support..

Now let's look it really, he said he want to affect all account, what the difference with this and a server variable ?

-That player won't manipulate that server variable but may have another.

-That new player will be affect by the server one but not by sql.

2nd point is more interesting imo cause let say he want to do a little freebie : "Ok for noel everyone come see Santa at lutie you'll get a reward". => that suppose we mark valid then false.

Well here in sql only already created char will benefit it.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

Using gettimetick(2) / 86400 will give a 'day tick' using epoch time. Will work till like 2036. I can't remember if it uses UTC time or server time though...

its UTC

http://www.eathena.ws/board/index.php?s=&showtopic=243105&view=findpost&p=1325351

dunno why seems like my topic nobody reads :ani_swt3:

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  205
  • Reputation:   19
  • Joined:  10/12/12
  • Last Seen:  

Oh, I missed the post in which he said it was for a daily quest o.O sorry about that.

Anyway I was not shutting down any suggestion, I was just poining out about the "what if not...". the aim was to look after some general methods as he said he was done with solving the problem.

I wrote a function in the past called "autocleanvar" to add a delay timer to a variable to auto-delete it automatically.

It's another approach, more complex, but possible too :P

Yeah exactly, I made this sort of script long ago when I was scripting for a server, or at least something that worked similar. Would be awesome to get it back :D
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...