[Tutorial] How to make a global Timescript
#4

Quote:
Originally Posted by RedFusion
View Post
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.
Reply


Messages In This Thread
How to make a global Timescript - by RedFusion - 10.08.2012, 03:47
Re: How to make a global Timescript - by Jarnu - 10.08.2012, 04:14
Re: How to make a global Timescript - by Matz - 10.08.2012, 17:45
Re: How to make a global Timescript - by Vince - 10.08.2012, 18:11
Re: How to make a global Timescript - by RedFusion - 10.08.2012, 18:46
Re: How to make a global Timescript - by MoDee - 24.08.2012, 19:04
Re: How to make a global Timescript - by RedFusion - 25.08.2012, 01:44
Re: How to make a global Timescript - by MoDee - 25.08.2012, 08:07

Forum Jump:


Users browsing this thread: 1 Guest(s)