Graal Forums

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

bloodpet 06-28-2004 07:22 AM

Free Time Script Example
 
NPC Code:

// This goes in the database (db)
if (created || initialized) {
t = s;
timeout = 1;
}
if (timeout) {
t++;
if (t>=86400)
t = 0; // resets time
s = t;

timeout = 1;
}



NPC Code:

// this goes in the weapon
i = s; // gets the curent time
h = int(i / 3600); // the hour
m = int((i - h * 3600) / 60); // the min
s = int((i - h * 3600) - (m * 60)); // the sec
if (h > 10) {
setstring this.p,AM; // changed to am and pm
}else {setstring this.p,PM;}
h ++;
if (h > 12) {
h -= 12; // 12 hour mode
}
if (m < 10) {
setstring this.m,0#v(m); // enables 01-09
}else {setstring this.m,#v(m);}

if (s < 10) {
setstring this.s,0#v(s); // enables 01-09
}else {setstring this.s,#v(s);}



*Note: you have to add something in here to show the time for instance:

NPC Code:

showimg 999,@ariel@bottom@#v(h):#s(this.m):#s(this.s) #s(this.p) #s,20,screenheight-30;
changeimgvis 999,5;
changeimgzoom 999,1;



If you find any bugs please post them here. Also if oy uhave any suggestions, suggest away. Im only here to help.

You need to stop the DB script befor you can set the time. Its scripted s oyou can shange server flags without disturbing the time, thank you for oyur support. ~bloodpet

I actualy thought the this.m and this.s were needed rather then doign some other if comands followed by multiple display scritps that get messy.....

WanDaMan 06-28-2004 07:34 AM

For starters, you don't need to set any strings what so ever to have a time script. Just use the variable for the total server time, which I can not recall at the current moment, but there is one, and some simply mathematics. No need for the complexity.

bloodpet 06-28-2004 07:46 AM

Quote:

Originally Posted by WanDaMan
For starters, you don't need to set any strings what so ever to have a time script. Just use the variable for the total server time, which I can not recall at the current moment, but there is one, and some simply mathematics. No need for the complexity.


yep.. thats all i did some simple mathematics.. and good point about having it just run on variables lemem change that.. It would be a little more cleaner that way anyways...

WanDaMan 06-28-2004 11:10 AM

I wasn't aiming the mathematics comment towards you, I just said it. But anyways... yeah, variables.

Anyways, how on earth have you changed your forums title after only eight posts? Also, please don't get me started on the title itself...

Ningnong 06-28-2004 12:34 PM

Please use code tags :/

Also, using timevar is far superior. It cuts out the need to use a db-npc.

Andy0687 06-28-2004 04:10 PM

Quote:

Originally Posted by WanDaMan
I wasn't aiming the mathematics comment towards you, I just said it. But anyways... yeah, variables.

Anyways, how on earth have you changed your forums title after only eight posts? Also, please don't get me started on the title itself...


Timevar, and anyone can change their title/avatar at any time

Loriel 06-28-2004 04:18 PM

Did you actually test this? s = #v(this.t);

Dach 06-28-2004 06:01 PM

Quote:

Originally Posted by Loriel
Did you actually test this? s = #v(this.t);

twas what I was thinking

Timevar isn't very exact, but it does get the job done. Whatever happened to timevar2? Last time I tried to use it, it didn't work x_x

osrs 06-28-2004 06:20 PM

Maybe you should change your avatar title. >_<

WanDaMan 06-28-2004 06:25 PM

Quote:

Originally Posted by Andy0687
Timevar, and anyone can change their title/avatar at any time

Oh, okay. Thanks :)

bloodpet 06-28-2004 08:20 PM

Quote:

Originally Posted by Ningnong
Please use code tags :/

Also, using timevar is far superior. It cuts out the need to use a db-npc.

timevar? never head of it.. I think i should look into that, sounds like a great idea. And code tags.. um
NPC Code:
this?


bloodpet 06-28-2004 08:21 PM

Quote:

Originally Posted by Loriel
Did you actually test this? s = #v(this.t);


No, I tested it befor I edited it whe ni used strings.. why? i cant really see without my glasses. When I get a new pair later today Ill check the script again and make sure its right..

ohh i forgot to take the #v( ) out fro mwhe ni had it as a string.. sorry.. lemem fix

Nappa 06-28-2004 08:30 PM

I think you made something it a bit more complicated then it ever needed to be.

bloodpet 06-28-2004 08:33 PM

Quote:

Originally Posted by Nappa
I think you made something it a bit more complicated then it ever needed to be.


and why do you say that? :p

Nappa 06-28-2004 08:33 PM

I've made a far simpler time script with light effects and everything in about 4-5 minutes using timevar, all in one npc.


All times are GMT +2. The time now is 03:11 AM.

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