Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 05-25-2001, 05:16 AM
LiquidIce00 LiquidIce00 is offline
RadioActive Monkeeh
LiquidIce00's Avatar
Join Date: Apr 2001
Location: dirty south
Posts: 2,112
LiquidIce00 is on a distinguished road
Send a message via ICQ to LiquidIce00 Send a message via AIM to LiquidIce00 Send a message via Yahoo to LiquidIce00
day/night script code

I just made this quickly in about 20 minutes , so it can be improved

I'll explain ...

It uses timevar (server-wide variable which adds 1 to itself every 5 seconds)

Table:
when timevar is ...
1 then on the server its 5 minutes
12 then on the server its 1 hour
288 then on the server its 1 day
8640 then on the server its 1 month
103680 then on the server its 1 year

so for example if timevar is 25 ..

the script would do this:

1)make this.checktime the timevar value

2)check to see if year is bigger (in this case its less than 1 year),
check for month (nope less than 1 month), check for day (nope),
check for hour( yes! ) 25 is bigger than 12 .. so that means that it is more than/or 1 hour...

3)Do While Loop...
here it will do this.. while this.checktime is more than 12 (which is 1 hour) take away 12 from this.checktime and then add 1 to this.hour (variable which keeps how many hours)
Here is the output:
1st loop run: this.hour = 1 , this.checktime=13
2nd looprun:this.hour=2, this.checktime=1

4)Continue checking ... check minutes( yes! )
yes, this.checktime is 1 from the last loop remember? so it is bigger or equal to 1 .. now do more loop..
While this.checktime is more than or equal to 1 add 1 to this.minute and take away 1 from this.checktime
Here is output:
1st loop: this.checktime=0, this.minute=1

5) Code is done!
Output:
this.checktime=0
this.hour=2
this.minute=1

Now here is the code , enuff talkin'


//NPC Made By LiquidIce *Owner* (UnholyNation)
//Please let me know if you want to use this script
//dont just be greedy and use it ..

//day/night part
//check time and such for right backpal
this.checktime=timevar;
//count years
this.year=0;
while (this.checktime>=103680) {
this.checktime-=103680;this.year++;
}
//count month
this.month=0;
while (this.checktime>=8640) {
this.checktime-=8640;this.month++;
}
//count day
this.day=0;
while (this.checktime>=288) {
this.checktime-=288;this.day++;
}
//count hour
this.hour=0;
while (this.checktime>=12) {
this.checktime-=12;this.hour++;
}
//count minute
this.minute=0;
while (this.checktime>=1) {
this.checktime-=1;this.minute++;
}
if (isonmap) {
if (this.hour<12) { setbackpal dusk3.png; }
else { setbackpal pics1.png }
}

if (!isonmap) { setbackpal pics1.png;}

//end backpal check
//end day/night
__________________
LiquidIce *Owner* (UnholyNation)
-UN Website
http://www.unholynation.com
-UN Forum
http://forums.unholynation.com
-
-the thinker
-

-
onwall2 for nonp2p (i suck at onwall)
Reply With Quote
  #2  
Old 05-25-2001, 06:16 AM
kyle0654 kyle0654 is offline
-. .`
kyle0654's Avatar
Join Date: Mar 2001
Posts: 1,000
kyle0654 will become famous soon enough
I'm gonna edit this...just multiply the last number on the line by the first on the next line to get the next number, it's the same as you had though
when timevar *
.2 then on the server its 5 minutes *
60 then on the server its 1 hour *
24 then on the server its 1 day *
30 then on the server its 1 month *
12 then on the server its 1 year
NPC Code:

this.minute = int(timevar / .2)%60;
this.hour = int(this.minute / 60)%24;
this.day = int(this.hour / 24)%30;
this.month = int(this.day / 30)%12;
this.year = int(this.month / 12);


hope that makes sense. You basically start with what you're fiding (minutes), find how many there are, divide by how many minutes were in 1 of the previous thing (timevar) and get the remainder when divided by the maximum of that type you can have (how many in an hour). The stuff in ()'s pertains to finding minutes. good job with your versoin though It got the job done, just would be pretty laggy when the numbers got higher;

-Kyle
Reply With Quote
  #3  
Old 05-25-2001, 06:35 AM
LiquidIce00 LiquidIce00 is offline
RadioActive Monkeeh
LiquidIce00's Avatar
Join Date: Apr 2001
Location: dirty south
Posts: 2,112
LiquidIce00 is on a distinguished road
Send a message via ICQ to LiquidIce00 Send a message via AIM to LiquidIce00 Send a message via Yahoo to LiquidIce00
I could make it really really short if i had made an actual arithmetics for it.. like i said i made it quick ;P
but thx for the adjust
__________________
LiquidIce *Owner* (UnholyNation)
-UN Website
http://www.unholynation.com
-UN Forum
http://forums.unholynation.com
-
-the thinker
-

-
onwall2 for nonp2p (i suck at onwall)
Reply With Quote
  #4  
Old 05-25-2001, 06:44 AM
LiquidIce00 LiquidIce00 is offline
RadioActive Monkeeh
LiquidIce00's Avatar
Join Date: Apr 2001
Location: dirty south
Posts: 2,112
LiquidIce00 is on a distinguished road
Send a message via ICQ to LiquidIce00 Send a message via AIM to LiquidIce00 Send a message via Yahoo to LiquidIce00
uhmm..
here is a little code for example if you want to have a little clock in your inventory and when you fire , it shows the time and date ...
I might make a version where it has the status bar of it also (like on g2k1 and X)

// NPC made by LiquidIce
//thx to Kyle for making a little
// 'arithmetics' =P
if (!isweapon&&(playerenters)) {
hide;
toweapons *Time;
}
if (weaponfired) {
this.minute = int(timevar / .2)%60;
this.hour = int(this.minute / 60)%24;
this.day = int(this.hour / 24)%30;
this.month = int(this.day / 30)%12;
this.year = int(this.month / 12);

if (this.minute<10) { setstring bclockminute,0#v(this.minute); }
else { setstring bclockminute,#v(this.minute); }

setstring bclockyear,#v(this.year);
setstring bclockmonth,#v(this.month);
setstring bclockday,#v(this.day);
setstring bclockhour,#v(this.hour);

say2
#xCurrent Time#y#b
Year: #s(bclockmonth)/#s(bclockday)/#s(bclockyear) #x#b
Time: #s(bclockhour):#s(bclockminute) #z;
setstring bclockyear,;
setstring bclockmonth,;
setstring bclockday,;
setstring bclockhour,;
setstring bclockminute,;

}
__________________
LiquidIce *Owner* (UnholyNation)
-UN Website
http://www.unholynation.com
-UN Forum
http://forums.unholynation.com
-
-the thinker
-

-
onwall2 for nonp2p (i suck at onwall)
Reply With Quote
  #5  
Old 05-25-2001, 06:51 AM
LiquidIce00 LiquidIce00 is offline
RadioActive Monkeeh
LiquidIce00's Avatar
Join Date: Apr 2001
Location: dirty south
Posts: 2,112
LiquidIce00 is on a distinguished road
Send a message via ICQ to LiquidIce00 Send a message via AIM to LiquidIce00 Send a message via Yahoo to LiquidIce00
my bad. .
Kyle , something is wrong with yours, I believe its going to negative values. . that method wont work =\
it works up to a certain ammount until when you divide it gives negative ammounts and returns 0 ..
Is it just me or is the code actually buggy?
(if the code is buggy the little clock wont work btw..)
__________________
LiquidIce *Owner* (UnholyNation)
-UN Website
http://www.unholynation.com
-UN Forum
http://forums.unholynation.com
-
-the thinker
-

-
onwall2 for nonp2p (i suck at onwall)
Reply With Quote
  #6  
Old 05-25-2001, 06:53 AM
LiquidIce00 LiquidIce00 is offline
RadioActive Monkeeh
LiquidIce00's Avatar
Join Date: Apr 2001
Location: dirty south
Posts: 2,112
LiquidIce00 is on a distinguished road
Send a message via ICQ to LiquidIce00 Send a message via AIM to LiquidIce00 Send a message via Yahoo to LiquidIce00
AH. so much posting so soon =D
thx to kyle I found a little problem
in the line where it says

while (this.checktime>=1) {

change to

while (this.checktime>=.2) {

and right below that

this.checktime-=1;this.minute++;

to

this.checktime-=.2;this.minute++;
__________________
LiquidIce *Owner* (UnholyNation)
-UN Website
http://www.unholynation.com
-UN Forum
http://forums.unholynation.com
-
-the thinker
-

-
onwall2 for nonp2p (i suck at onwall)
Reply With Quote
  #7  
Old 05-25-2001, 07:06 AM
kyle0654 kyle0654 is offline
-. .`
kyle0654's Avatar
Join Date: Mar 2001
Posts: 1,000
kyle0654 will become famous soon enough
Mine doesn't seem to have any problems...I wouldn't do it that way if I made one though...I'd probably use an array or something, but it's easier to explain and use that way. The only possible bug is that the int and % is mixing up. try
(int(var / #))%#;
if you still can't get it to work
Reply With Quote
  #8  
Old 05-25-2001, 07:39 AM
LiquidIce00 LiquidIce00 is offline
RadioActive Monkeeh
LiquidIce00's Avatar
Join Date: Apr 2001
Location: dirty south
Posts: 2,112
LiquidIce00 is on a distinguished road
Send a message via ICQ to LiquidIce00 Send a message via AIM to LiquidIce00 Send a message via Yahoo to LiquidIce00
I'll try later but when timevar was high it was brokage...
maybe thats it because I was thinking and I wasnt sure what was doing wrong
__________________
LiquidIce *Owner* (UnholyNation)
-UN Website
http://www.unholynation.com
-UN Forum
http://forums.unholynation.com
-
-the thinker
-

-
onwall2 for nonp2p (i suck at onwall)
Reply With Quote
  #9  
Old 05-25-2001, 12:19 PM
CrazedMerlin CrazedMerlin is offline
Some Guy :\
Join Date: Apr 2001
Posts: 3,619
CrazedMerlin is on a distinguished road
Send a message via AIM to CrazedMerlin Send a message via Yahoo to CrazedMerlin
I wanna be smart
heh
__________________

ICQ: 117881194
AIM: TehWizad
E-Mail: [email protected]
Reply With Quote
  #10  
Old 07-18-2001, 02:30 PM
Cybnext_Design Cybnext_Design is offline
Registered User
Join Date: Jun 2001
Posts: 244
Cybnext_Design is on a distinguished road
Send a message via AIM to Cybnext_Design
bugged...

When ever i try and use a code like that, i always get 41 months. Does anyone know what i could be doing wrong to get such a high number of months?

And im not using kyle's way.
__________________
Graal2001 NPC Maker
Frolic Owner
Aim: C Y B N E X T
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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:36 PM.


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