Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 10-10-2005, 04:04 PM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
time

here's my current time/day/night script, I wanted to make it so it was more like real time, and possible modify it so it matched current time in real time. How would I do this?
NPC Code:
//#CLIENTSIDE
if(created||timeout){
this.seconds=timevar%60;
this.minutes=int(timevar/60)%60;
this.hours=int(timevar/3600)%24;
showimg 888,dr-hourglass.png,293,10;
showtext 889,316,10,Comic Sans,b,#v(this.hours):#v(this.minutes):#v (this.seconds);
changeimgvis 888,5;
changeimgvis 889,5;
changeimgzoom 888,.85;
if(this.hours==16) {
setbackpal dusk1.png;
}
if(this.hours==20){
setbackpal dusk3.png;
}
if(this.hours==24){
setbackpal dusk5.png;
}
if(this.hours==1) {
setbackpal dusk4.png;
}
if(this.hours==4) {
setbackpal dusk3.png;
}
if(this.hours==5) {
setbackpal dusk2.png;
}
if(this.hours==6) {
setbackpal pics1.png;
}
timeout=.05;

}

Reply With Quote
  #2  
Old 10-10-2005, 08:07 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Make a script that counts, I guess.

That, or make creative use of timevar. It increases by one every 5 seconds. Use it to your advantage, boy.
__________________
Skyld
Reply With Quote
  #3  
Old 10-10-2005, 08:50 PM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
Quote:
Originally Posted by Skyld
Make a script that counts, I guess.

That, or make creative use of timevar. It increases by one every 5 seconds. Use it to your advantage, boy.
yeah I tried something like int(timevar*.2)%60 but that 'froze' the time
Reply With Quote
  #4  
Old 10-10-2005, 11:38 PM
ZeLpH_MyStiK ZeLpH_MyStiK is offline
Scripter
ZeLpH_MyStiK's Avatar
Join Date: May 2003
Location: NYC
Posts: 553
ZeLpH_MyStiK is on a distinguished road
Send a message via MSN to ZeLpH_MyStiK Send a message via Yahoo to ZeLpH_MyStiK
Quote:
Originally Posted by excaliber7388
yeah I tried something like int(timevar*.2)%60 but that 'froze' the time
why would you multiply by .2? since it increases by one every five seconds, you'd multiply by 5. Plus timevar is the amount of time passed since the server was up. You would have to find a way around the different days in a month (28,30,31), the leap year increments (.25 day every year)...and etc.
__________________
Reply With Quote
  #5  
Old 10-10-2005, 09:10 PM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
If you want to be the real time, use timevar2,

PHP Code:
timezone = -5// GMT-5 (EST)
seconds int(timevar2 60);
minutes int((timevar2 60) % 60);
hours int((timevar2 / (60 60)) % 24) + (timezone 1); 
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #6  
Old 10-12-2005, 02:33 AM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
Hmm, not gonna restart my server anyway XD, but is there a way to modify this, without disabling the ammount for hours min, etc?
Reply With Quote
  #7  
Old 10-12-2005, 03:50 AM
ZeLpH_MyStiK ZeLpH_MyStiK is offline
Scripter
ZeLpH_MyStiK's Avatar
Join Date: May 2003
Location: NYC
Posts: 553
ZeLpH_MyStiK is on a distinguished road
Send a message via MSN to ZeLpH_MyStiK Send a message via Yahoo to ZeLpH_MyStiK
Quote:
Originally Posted by excaliber7388
Hmm, not gonna restart my server anyway XD, but is there a way to modify this, without disabling the ammount for hours min, etc?
you can use another variable:
NPC Code:

this.time=timevar-2;

__________________
Reply With Quote
  #8  
Old 10-12-2005, 12:25 PM
Polo Polo is offline
Classic Systems Admin
Join Date: Sep 2002
Location: Vancouver, Canada
Posts: 735
Polo is on a distinguished road
Send a message via AIM to Polo
On Classic we have a 24 hour clock for doing accurate day/night. We use timevar2 on clientside (seconds since they turned thier computer on). To change this into somthing synced for everyone, we calculate the offset to the serverside timevar2 (unix time) when they log in, and then adjust for this before calculating the actual time.

Theoretically, everyone is then getting thier times as unix time, give or take a small error for lag reasons.
__________________
Be good little players, or Master Storm will ban you!



Proof that the staff are crazy..
*Ghost Pirate: I'm a little teacup short and stubbe here is my raygun here is my butt
DragonX: Jumping jack rabbits Batman! Our eggo waffles have been stolen! To the batmobile Robin!
X-Mann (RC): I have a head ache
Reply With Quote
  #9  
Old 10-12-2005, 10:15 PM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
here's what I'm using right now, but everyone has different times, and I think the time changes when you log on x_X suggestions?

NPC Code:
//#CLIENTSIDE
if(created||timeout){
this.hour=timevar2+16*3600;
this.min=timevar2-24*60;
this.seconds=int(timevar2)%60;
this.minutes=int(this.min/60)%60;
this.hours=int(this.hour/3600)%24;
showimg 888,dr-hourglass.png,290,10;
showtext 889,316,10,Comic Sans,b,#v(this.hours):#v(this.minutes):#v(this.sec onds);
changeimgvis 888,5;
changeimgvis 889,5;
changeimgzoom 888,.85;
if(isonmap){
if(this.hours==16&&this.hours<20) {
setbackpal dusk1.png
}
if(this.hours=>17&&this.hours<20){
setbackpal dusk3.png
}
if(this.hours=>20&&this.hours<24){
setbackpal dusk4.png
}
if(this.hours==24){
setbackpal dusk5.png
}
if(this.hours=<3) {
setbackpal dusk4.png
}
if(this.hours==4) {
setbackpal dusk3.png
}
if(this.hours==5) {
setbackpal dusk1.png
}
if(this.hours=>6&&this.hours<16) {
setbackpal pics1.png
}
}
if(!isonmap){setbackpal pics1.png}
timeout=.05;

}

Reply With Quote
  #10  
Old 10-12-2005, 11:50 PM
ZeLpH_MyStiK ZeLpH_MyStiK is offline
Scripter
ZeLpH_MyStiK's Avatar
Join Date: May 2003
Location: NYC
Posts: 553
ZeLpH_MyStiK is on a distinguished road
Send a message via MSN to ZeLpH_MyStiK Send a message via Yahoo to ZeLpH_MyStiK
Quote:
Originally Posted by Polo
On Classic we have a 24 hour clock for doing accurate day/night. We use timevar2 on clientside (seconds since they turned thier computer on). To change this into somthing synced for everyone, we calculate the offset to the serverside timevar2 (unix time) when they log in, and then adjust for this before calculating the actual time.

Theoretically, everyone is then getting thier times as unix time, give or take a small error for lag reasons.
So I'm assuming once it's synced, client computers will do the addition of seconds and minutes and etc in a timeout loop? It's not accurate since the calculation will take cpu speed and throw off following loops. Plus, as Spark has said before, having a 24 hour clock will mean that half of your players will always play in the dark while the other half play in the light.


As for excaliber7388's problem, i don't see anything that would cause everyone to have different times. However, setbackpal is very outdated and should no longer be used. Instead, replace with seteffect.
__________________
Reply With Quote
  #11  
Old 10-13-2005, 03:37 AM
Polo Polo is offline
Classic Systems Admin
Join Date: Sep 2002
Location: Vancouver, Canada
Posts: 735
Polo is on a distinguished road
Send a message via AIM to Polo
Quote:
Originally Posted by ZeLpH_MyStiK
So I'm assuming once it's synced, client computers will do the addition of seconds and minutes and etc in a timeout loop? It's not accurate since the calculation will take cpu speed and throw off following loops. Plus, as Spark has said before, having a 24 hour clock will mean that half of your players will always play in the dark while the other half play in the light.
Actually, timeout is running using the system clock, and is therefore pretty accurate regardless of the users CPU. As a general comparison, between my Intel Pentium3 450mhz, and my AMD AthlonXP 2600+ Barton, there is no discernable difference, and I think most people would agree that these are very different levels of CPU.

The calculation is not summing an ammount of seconds periodically anyway, it is always resalsculating the time from the stored offset, and the clientside timevar2. If we count the difference caused by the delay transmitting the offset back to the player as negligable, then the clock is acurate enough to create evolving day/night and weather effects. We can even creat extra snow in winter for example, by correctly identifying weather changes and simulating these as sinusoids (using the synced clock, with varying offsets and periods).

As for players playing in the dark, as weather and day/night are not central to the theme of Classic, users have the option to disable them (infact, for all players these effects are disabled by default).
__________________
Be good little players, or Master Storm will ban you!



Proof that the staff are crazy..
*Ghost Pirate: I'm a little teacup short and stubbe here is my raygun here is my butt
DragonX: Jumping jack rabbits Batman! Our eggo waffles have been stolen! To the batmobile Robin!
X-Mann (RC): I have a head ache
Reply With Quote
  #12  
Old 10-12-2005, 11:43 PM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
Time changes when you log in, different times for everyone x_X bad
Reply With Quote
  #13  
Old 10-13-2005, 12:04 AM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
How do you sync it???(And it changes EVERY time you log on in my current script
Reply With Quote
  #14  
Old 10-13-2005, 12:21 AM
ZeLpH_MyStiK ZeLpH_MyStiK is offline
Scripter
ZeLpH_MyStiK's Avatar
Join Date: May 2003
Location: NYC
Posts: 553
ZeLpH_MyStiK is on a distinguished road
Send a message via MSN to ZeLpH_MyStiK Send a message via Yahoo to ZeLpH_MyStiK
Quote:
Originally Posted by excaliber7388
How do you sync it???(And it changes EVERY time you log on in my current script
It's supposed to change? Since timevar2 is a freakin' nanosecond precisioned counting machine! j/k but timevar2 increases whether you're on player or not, same goes for timevar.
__________________
Reply With Quote
  #15  
Old 10-13-2005, 02:37 AM
Ajira Ajira is offline
Poont.
Join Date: Oct 2004
Location: NY, USA
Posts: 477
Ajira is on a distinguished road
Quote:
Originally Posted by excaliber7388
How do you sync it???(And it changes EVERY time you log on in my current script
It's because it's CLIENTSIDE. It's the seconds since your computer's on. If you do it serverside, it should be the same. Or at least sync it with the serverside when you log on first.
__________________
Liek omigosh.

Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 10:41 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.