Date + Time bugs - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Date + Time bugs (
/showthread.php?tid=440922)
Date + Time bugs -
Stefand - 31.05.2013
I made a date + time stamp thing in the corner of the screen.
But when it turns 22:00 or 23:00 or 0:00
it goes to "0-2:05:23" @ the time.
this is the code:
pawn Код:
public settime(playerid)
{
new string[256],year,month,day,hours,minutes,seconds;
getdate(year, month, day), gettime(hours, minutes, seconds);
format(string, sizeof string, "%d/%s%d/%s%d", day, ((month < 10) ? ("0") : ("")), month, (year < 10) ? ("0") : (""), year);
TextDrawSetString(Date, string);
format(string, sizeof string, "%s%d:%s%d:%s%d", (hours < 10) ? ("0") : (""), hours-2, (minutes < 10) ? ("0") : (""), minutes, (seconds < 10) ? ("0") : (""), seconds);
TextDrawSetString(Time, string);
}
Re: Date + Time bugs -
Konstantinos - 31.05.2013
It shows a '-'? By the way, use
instead of checking if it is lower than 10 and adding 0 and all that. It prints the same result!
Re: Date + Time bugs -
Stefand - 31.05.2013
Quote:
Originally Posted by _Zeus
It shows a '-'? By the way, use
instead of checking if it is lower than 10 and adding 0 and all that. It prints the same result!
|
yes it shows a - but I think its because of Hours-2, but that is because I want the server to have the same GMT as my country
Re: Date + Time bugs -
Konstantinos - 31.05.2013
Just try this one
pawn Код:
gettime(hours, minutes, seconds);
hours -= 2;
if(hours == -2) hours = 22;
else if(hours == -1) hours = 23;
format(string, sizeof string, "%02d:%02d:%02d", hours, minutes, seconds);
Just to prevent it from being negative if it is equal to 0/1.