Quote:
Originally Posted by RedFusion
pawn Code:
if(Hour < 10 && Minute < 10) format(timestring,sizeof(timestring),"0%i:0%i",Hour,Minute); if(Hour < 10 && Minute > 9) format(timestring,sizeof(timestring),"0%i:%i",Hour,Minute); if(Hour > 9 && Minute < 10) format(timestring,sizeof(timestring),"%i:0%i",Hour,Minute); else if(Hour > 9 && Minute > 9) format(timestring,sizeof(timestring),"%i:%i",Hour,Minute);
These lines formats a string, the string to be shown to the players.
The 3 first lines adds a 0 infront of Minutes Or hours; If any or both of them are less than 10 (2 characters)
Otherwise it will look like "2:54" instead of "02:54".
The last line checks if both Minutes and Hours are greater than 9 (2 characters each) If this is the case, no 0 is added infront of any of them. Example: 20:43
-----
|
Oh god, why? At least, when writing a tutorial do your research.
pawn Code:
format(timestring, sizeof(timestring), "%02d:%02d", Hour, Minute);
This is all you need. Makes sure that the number is 2 digits long and will pad it with zeros if it's not.