Server Time...

Hmmmm, if anybody needs this, I’ll just post it on here…It is a time system…

Enter the level to start the clock…

server.second - the seconds
server.minute - the minutes
server.hour - the hour

// NPC by Alex
if(playerenters){
  timeout = 0.05;
}
if(timeout){
  if(strtofloat(#s(server.second))<60){
    if(strtofloat(#s(server.second))<10){
      setstring server.second,0#v(strtofloat(#s(server.second))+1);
    }
    if(strtofloat(#s(server.second))>=10){
      setstring server.second,#v(strtofloat(#s(server.second))+1);
    }
  }
  if(strtofloat(#s(server.second))>=60){
    if(strtofloat(#s(server.minute))<60){
      setstring server.second,00;
      if(strtofloat(#s(server.minute))<10){
        setstring server.minute,0#v(strtofloat(#s(server.minute))+1);
      }
      if(strtofloat(#s(server.minute))>=10){
        setstring server.minute,#v(strtofloat(#s(server.minute))+1);
      }
    }
    if(strtofloat(#s(server.minute))>59){
      setstring server.second,00;
      setstring server.minute,00;
      if(strtofloat(#s(server.hour))<24){
        if(strtofloat(#s(server.hour))<10){
          setstring server.hour,0#v(strtofloat(#s(server.hour))+1);
        }
        if(strtofloat(#s(server.hour))>=10){
          setstring server.hour,#v(strtofloat(#s(server.hour))+1);
        }
      }
      if(strtofloat(#s(server.hour))>=24){
        setstring server.hour,00;
      }
    }
  }
  timeout = 1;
}

You can use this to look at it in a level, or for testing O.o

if(created){ message #s(server.hour):#s(server.minute):#s(server.second); }

Looks nice. Good job.

holy cow. im sure you can do something like this.seconds = strtofloat(server.whatever) at the beginning of the timeout. save some space, but you dont really need to.

also gscript is sequential so you dont need some of those if statements.

gj on making something though. more people need to do this.

Wont work for me. I dont know why…

you probably need to initialize the server strings

I dont get it… its not serverside time, its only for one level? its pointless?

For level time isnt that why you have timeout, timeout will suffice

if (playerenters){
  time=0;
  timeout=0.05;
}

if (timeout){
  time++;
  temp=time;
  hours=int(temp/3600);
  temp=temp%3600;
  minutes=int(temp/60);
  temp=temp%60;
  seconds=temp;
  message #v(hours):#v(minutes):#v(seconds);
  timeout=1;
}

Your trying to do something like this I think? and so its basically a stop watch?

If you wanted server wide time you use timevar. So… I dont really understand the point in your script

Well, the thing is Tricxta, when ever you update the level the clock resets…

Why not make it an NPCw while running off of timevar, then use some variables like “timeminute”, so it could be read by other NPCs by the player.

generally what a stop watch does… derp -_- if i wanted i could save time to a server string then yer it wouldnt reset…

also beholder im not familiar with what NPCw is o.0 care to explain?

Also I think alex’s and my way are adequate enough, time var would keep things good in terms of counting even when the player lags but I dont think its really needed :expressionless:

NPCw is NPC weapon

Oi.
You could do

server.minutes = server.seconds / 60;
server.hours = server.minutes / 60;

could you not?

Math helps a lot

Sent from my MB860 using Tapatalk

Well, the issue was, if the seconds were at 50, then the minute would be seen as .833333333…

And, tric, the reason I didn’t use timever is because I wan’t it to be more accurate (every second)…

___Merged doublepost__________________

And, tric, it is supposed to be server time to be used by any script x.x Basically, put it in a level you don’t really use (or make it a weapon O.o) and enter the level to initialize it

Also, to add to this, it was made a bit longer because of my checks if <10 ot >=10…

Basically, making it look presentable…

so if the time was 10 hour 10 minute and 9 seconds…

it would be

10:10:09

Notice the 0 xP

Normally, it would just be 10:10:9

Just use timevar and don’t display seconds Mr. PickyPants.

what about abs?
Seriously, absolute value.

___Merged doublepost__________________

Have you tried it, instead of criticizing it!?

timevar increases once every 5 seconds. you can fake it by having a timer reset to 0 once timevar changes, then have that number increase up to 5. abs means “absolute” yes, as in. abs(-3846) = 3846, shaves off negatives.

but does abs round too?

No, it doesn’t, to my experience with it…and in normal math, it doesn’t round either.

Nope, just tested it. It just did as Beholder said, shaved off the negatives.

this.shit = (timevar+5760)%17280;
this.hours = int((this.shit/720)%12);
this.minutes = int((this.shit/12)%60);