Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Date/Time Script (https://forums.graalonline.com/forums/showthread.php?t=62057)

ZeLpH_MyStiK 11-03-2005 05:05 AM

Date/Time Script
 
1 Attachment(s)
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!

raiden0899 11-03-2005 05:38 AM

Quote:

Originally Posted by vBulletin Message
Invalid Attachment specified. If you followed a valid link, please notify the webmaster

o.o

napo_p2p 11-03-2005 05:46 AM

I am sure this will be helpful to many :D.

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!

ZeLpH_MyStiK 11-03-2005 05:54 AM

Quote:

Originally Posted by napo_p2p
I am sure this will be helpful to many :D.
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

napo_p2p 11-03-2005 05:59 AM

Quote:

Originally Posted by ZeLpH_MyStiK
yea i fixed that in the edit

Didn't see that :P.

Again, nice script :D.

ZeLpH_MyStiK 11-03-2005 06:14 AM

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

napo_p2p 11-03-2005 06:30 AM

Don't worry about it until 2100.

Lance 11-03-2005 07:01 AM

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.

ZeLpH_MyStiK 11-03-2005 07:09 AM

I havent figured out how the calendar works yet, so bear with me =p
Until then, this is a loose approximation as you said.

Dach 11-04-2005 12:12 AM

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.

ZeLpH_MyStiK 11-04-2005 03:23 AM

That is true Chad. I imagine a script like that would take a few to execute.


All times are GMT +2. The time now is 09:54 PM.

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