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