Date + Time bugs
#1

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);
}
Reply
#2

It shows a '-'? By the way, use
pawn Код:
%02d
instead of checking if it is lower than 10 and adding 0 and all that. It prints the same result!
Reply
#3

Quote:
Originally Posted by _Zeus
Посмотреть сообщение
It shows a '-'? By the way, use
pawn Код:
%02d
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
Reply
#4

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.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)