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 11-03-2005, 05:05 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
Date/Time Script

Since many people have been asking about this, I figured I'd make something as an example for educational purposes only. This is done in gs2, and must be used serverside online for it to be accurate since timevar2 is different clientside and serverside. The script is commented, but if you have any questions, post here =) enjoy!
Attached Files
File Type: txt date_time_script.txt (6.0 KB, 213 views)
__________________

Last edited by ZeLpH_MyStiK; 11-03-2005 at 05:31 AM..
Reply With Quote
  #2  
Old 11-03-2005, 05:38 AM
raiden0899 raiden0899 is offline
Registered User
raiden0899's Avatar
Join Date: Oct 2004
Posts: 192
raiden0899 is on a distinguished road
Quote:
Originally Posted by vBulletin Message
Invalid Attachment specified. If you followed a valid link, please notify the webmaster
o.o
Reply With Quote
  #3  
Old 11-03-2005, 05:46 AM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
I am sure this will be helpful to many .

EDIT:
A very small correction...

The sendtorc line should read:
sendtorc(this.hour@":"@this.minute@":"@this.second @" "@this.time@" GMT on "@this.day@", "@this.month@" "@this.date@", "@this.year);

In code blocks:
NPC Code:
sendtorc(this.hour@":"@this.minute@":"@this.second  @" "@this.time@" GMT on "@this.day@", "@this.month@" "@this.date@", "@this.year);



Quote:
Originally Posted by raiden0899
o.o
Lies!
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
Reply With Quote
  #4  
Old 11-03-2005, 05:54 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 napo_p2p
I am sure this will be helpful to many .
A very small correction...

The sendtorc line should read:
sendtorc(this.hour@":"@this.minute@":"@this.second @" "@this.time@" GMT on "@this.day@", "@this.month@" "@this.date@", "@this.year);
yea i fixed that in the edit
__________________
Reply With Quote
  #5  
Old 11-03-2005, 05:59 AM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
Quote:
Originally Posted by ZeLpH_MyStiK
yea i fixed that in the edit
Didn't see that :P.

Again, nice script .
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
Reply With Quote
  #6  
Old 11-03-2005, 06:14 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
hehe thank you =)
althought according to lance, the script will be off around 2100, so i guess i'll figure out how gregorian calendars work and implement it in gscript now =D
__________________
Reply With Quote
  #7  
Old 11-03-2005, 06:30 AM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
Don't worry about it until 2100.
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
Reply With Quote
  #8  
Old 11-03-2005, 07:01 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 attachment
NPC Code:
  this.year = 1970 + int(this.temp / 31557600);
// 31557600 = 60 secs/min * 60 mins/hr * 24 hrs/day * 365.25 days/year

What calendar year has 365.25 days in it? If you're going to take the easy way out, at least find a more accurate number to divide by. I don't recommend taking the easy way out.

Quote:
NPC Code:
  this.monthdays = {31,28.25,31,30,31,30,31,31,30,31,30,31};
// the number of days for each month

What month has 28.25 days in it? See above.

Quote:
NPC Code:
  if (this.hour > 11) {
this.time = "PM";
}else this.time = "AM";

Consistency of formatting is important.
Reply With Quote
  #9  
Old 11-03-2005, 07:09 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
I havent figured out how the calendar works yet, so bear with me =p
Until then, this is a loose approximation as you said.
__________________
Reply With Quote
  #10  
Old 11-04-2005, 12:12 AM
Dach Dach is offline
call me Chad, it's cooler
Dach's Avatar
Join Date: Aug 2002
Posts: 1,899
Dach is on a distinguished road
The only way to find the exact date at any time you need to iterate from the beginning date and acrue your date that way.
There isn't any real way to derive the exact date from a bunch of seconds with some simple equation. There will always be some days that your year will not come out right.

Note: the way you an I both derive the year in our scripts will produce bad results when nearing the turn of the year on certain years. I know mine will be off at the end quarter of Dec 31 if there is but one leap year between the current date and my subtracted date. I don't really feel like figuring out exactly when yours will be off, but I'll guess that it will be on the first portions of Jan 1 on all non leap years.
__________________
Scripting Documents:Old Script Documentation-Movement Tutorial

Last edited by Dach; 11-04-2005 at 01:02 AM..
Reply With Quote
  #11  
Old 11-04-2005, 03:23 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
That is true Chad. I imagine a script like that would take a few to execute.
__________________
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 07:35 AM.


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