Use time of day as variable

Hi guys!

I’d like to make events at the same hour every day, to make the server more dynamic, and encourage people to log at the same time.

What is the proper use of timevar to manage server-side events at a given time of day?

Thanks for your help!


I managed to do this:

if (playerenters) {
message #v(strtofloat(#s(timevar)));
timeout = 0.5;
if (timeout){
message #v(((timevar/100-867300)*5));
timeout = 0.5;

But all I get is a serverside counter that increments every 5 seconds.

The thing is the total value for the var seems to be huge and ever increasing, how can you isolate time in a 24h cycle??

timevar increases by 1 every 5 seconds. It appears that the server software here sends this to the client every 5 seconds as well, so I assume the value will be as expected each time the client connects (as in not reset). The server tells the client the value of timevar is the number of seconds (divided by 5) since 01/01/1970 - 11078 days. (Apparently Stefan coded it that way, so they reproduced it for consistency.)

It should be pretty easy to figure out how to use this base as a means of tracking time.

Oh great this is a classic timestamp then, I should be able to figure out a formula to turn this into a date, although my brains hurt too much to do this right now.
it does some of the math for you
very useful
much practical

My timestamp is around 86700000

which gets me to Sat, 30 Sep 1972 11:20:00 GMT

If I multiply it by 5 (considering it increases by 1 every 5 secs)

I get to Tue, 27 Sep 1983 08:40:00 GMT

Either way I don’t get it.

Can we use modulo in graal? That’d be the key for weekly or daily events


By dividing with Epoch’s timestamp, I found out that if you multiply graal’s timestamp by 16, you get to december 24, at the right hour of the day.

So this: “timevar*16 + 2937600”

Gets you today’s timestamp GMT.


I mean, you could still just use timevar. 24 hours in timevar = [(24h)(60m)(60s)] / 5 = 17280. Note: Five is used because five real seconds are one timevar. So with this information we may be able to create daily events with a script that works as following.

[CODE]if (playerenters || timeout){
this.timer = timevar;
this.totaltime = 17280;
this.worldTime = this.timer%this.totaltime;
message #v(this.worldTime);
timeout = .2;

if (timeout && this.worldTime > 8640 && this.worldTime < 10000){
message Yo, it’s time to play n’ shit!;
So, if the values are between certain ones, you could have events take place at those specific times. Increase the initial totaltime by multiplying it by seven if you’d like to have events based on things that are weekly. I could have completely missed your point with this, though.

Note the subtraction above…


Missed that one on first reading, getting back to calculator

___Merged doublepost__________________

Here’s the final product:

(Plz somebody tell me the syntax to quote text)

// NPC made by Fredi

if (timeout||playerenters){
T = timevar*5 + 957139200; // Timestamp of current GMT
message World Time: #e(0,2,#v(T%86400/3600)):#e(0,2,#v(T%3600/60)):#v(T%60);

this.H=T%86400/3600; // Hour of the day
this.M=T%3600/60; // Minutes
this.S=T%60; // Seconds
if (this.S >34 && this.S <= 35) { //Lay green rupee between 30 and 35 seconds
lay greenrupee;
timeout = 1;

The first part displays the current GMT time, the last one gives you hours minutes and seconds so you can start events whenever you want during the day.

My example drops a useless green rupee each second between 35 and 40 seconds, each minute.

I suggest we all try to make events on our respective servers, and make them at different hours so there’s always a place to hang out.

I’m gonna make a clock weapon to show current time from anywhere.

I knew someone had the exact answer.

I’m not surprised it’s you.

Graal City will soon be invaded a few times a day!

You came up with the exact answer yourself. That’s better than mindlessly copying someone else who threw numbers together until it worked.

Is that how Spooon codes?
I know it isn’t but I can picture so well a jaded angsty young man trying to code by randomness, I like the image.

Yeah, I was a developer on Classic because I didn’t know how to do anything. Maybe the reason why I don’t like helping people can be partly attributed to how Codr just acted and how Twiggy and others have acted in the past. It’s much easier to yell at people than take bullshit like that.

Ignoring the fact that I don’t care if I bother you in particular, what exactly did I do wrong? The way your calculations were done show that you didn’t actually know what was going on with the value of timevar. I would’ve said the same to anyone because of that. fredi125 has it done in a way that’s consistent with the way it functions and is guaranteed to always produce expected results without question. That’s a good thing and he should be satisfied that he asked for actual clarification and not just something that happens to work.

I understand what timevar is and know how to use it; regardless, I got those numbers from Beholder. Not a code that Beholder made but from Beholder directly from Skype. I’ve been making an effort to be helpful instead of aggressive towards people on these forums, so while I do that perhaps you should try to be less of a spiteful cunt.

You sound like an old couple arguing over details that don’t matter :stuck_out_tongue:

Hmm… really? I’m not seeing much of a difference between what you did and what I did. Except that mine was actually a correction and not SOLELY an attempt to be negative. Please don’t even try to say that wasn’t what that was.

So, on the constructive side, what would you guys like to see happening in Graal City a few times a day? (Or anywhere else)

Spooon and codr take eachother in their arms and do a beautiful dance