22.06.2012, 22:27
Hello there, I have a clock that I use and I seem to have a bit of a problem.
When the hour is below 10 and the minutes and seconds are below 10, it shows like this:
1:2:8
I want it to show like this:
01:02:08
It's not major, but it's just to make the display nicer looking.
Here is my current code:
Thank you guys!
When the hour is below 10 and the minutes and seconds are below 10, it shows like this:
1:2:8
I want it to show like this:
01:02:08
It's not major, but it's just to make the display nicer looking.
Here is my current code:
pawn Код:
public ClockUpdate()
{
for(new x = 0; x < MAX_PLAYERS; x++)
{
if(Logged[x] == 1)
{
new string[12];
Second++;
format(string, sizeof(string), "%i:%i:%i", Hour, Minute, Second);
if(Hour < 10)
{
format(string, sizeof(string), "0%i:%i:%i", Hour, Minute, Second);
}
if(Minute < 10)
{
format(string, sizeof(string), "%i:0%i:%i", Hour, Minute, Second);
}
if(Second < 10)
{
format(string, sizeof(string), "%i:%i:0%i", Hour, Minute, Second);
}
if(Second == 60)
{
if(Minute == 59)
{
if(Hour == 23)
{
Hour = 0;
Minute = 0;
Second = 0;
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(Player[i][Faction] == 0)
{
SendClientMessage(i, ORANGE, "Your check is ready to be picked up. Please head to the Job Center to get it.");
}
else
{
SendClientMessage(i, ORANGE, "Your check is ready to be picked up. Please head to your headquarters to get it.");
}
}
}
format(string, sizeof(string), "0%i:0%i:0%i", Hour, Minute, Second);
}
else
{
Hour ++;
Minute = 0;
Second = 0;
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(Player[i][Faction] == 0)
{
SendClientMessage(i, ORANGE, "Your check is ready to be picked up. Please head to the Job Center to get it.");
}
else
{
SendClientMessage(i, ORANGE, "Your check is ready to be picked up. Please head to your headquarters to get it.");
}
}
}
format(string, sizeof(string), "%i:0%i:0%i", Hour, Minute, Second);
}
}
else
{
Minute ++;
Second = 0;
format(string, sizeof(string), "%i:%i:0%i", Hour, Minute, Second);
}
}
TextDrawSetString(Clock, string);
SetWorldTime(Hour);
}
}
return 1;
}