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, 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
  #5  
Old 10-10-2005, 10: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:
% 24) + (timezone + 1);
that would change the ammount of hours allowed, and the time, I just need to find out how to change the time
Reply With Quote
  #6  
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
  #7  
Old 10-11-2005, 09:34 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
I just need it to count hours and such, the other stuff would be easy to add anyway, I am still having trouble setting the time though. Can you edit the timevar? Or is there another way? Like:
NPC Code:
 if(created){
timevar=timevar-2;
}


Any help?

Last edited by excaliber7388; 10-11-2005 at 10:22 PM..
Reply With Quote
  #8  
Old 10-11-2005, 11:51 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
I just need it to count hours and such, the other stuff would be easy to add anyway, I am still having trouble setting the time though. Can you edit the timevar? Or is there another way? Like:
NPC Code:
 if(created){
timevar=timevar-2;
}


Any help?
o.O err timevar is a builtin variable. the only way to change timevar is reset your server and it will begin counting at 0 again. Use '%' to figure out the minutes, and hours, and such.
__________________
Reply With Quote
  #9  
Old 10-12-2005, 12:50 AM
Lance Lance is offline
dark overlord
Lance's Avatar
Join Date: Sep 2003
Location: Space Jam Mountain
Posts: 5,072
Lance is on a distinguished road
Quote:
Originally Posted by ZeLpH_MyStiK
o.O err timevar is a builtin variable. the only way to change timevar is reset your server and it will begin counting at 0 again. Use '%' to figure out the minutes, and hours, and such.
No, no, it won't.
Reply With Quote
  #10  
Old 10-12-2005, 01:18 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 Lance
No, no, it won't.
Isn't it server uptime?
__________________
Reply With Quote
  #11  
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
  #12  
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
  #13  
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
  #14  
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
  #15  
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
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 06:58 PM.


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