Adding a 0 to a one-digit in a timer
#1

Hi,
I'm trying to use the following code to add a 0 if the digit is below 10, but it doesnt appear on the textdraw:
Код:
new wh_alert_seconds[2], wh_seconds[2];

			if(seconds < 10)   format(wh_seconds, sizeof(wh_seconds), "0%d", seconds); else format(wh_seconds, sizeof(wh_seconds), "%d", seconds);
			if(alert_seconds < 10)  format(wh_alert_seconds, sizeof(wh_alert_seconds), "0%d", alert_seconds); else format(wh_alert_seconds, sizeof(wh_alert_seconds), "%d", alert_seconds);
Any tip?

Thanks.
Reply
#2

No if-then/else required:
PHP код:
format(wh_secondssizeof(wh_seconds), "%02d"seconds);
format(wh_alert_secondssizeof(wh_alert_seconds), "%02d"alert_seconds); 
Reply
#3

Is there a specific reason you're storing those as strings and not as integers?
Reply
#4

Quote:
Originally Posted by Abagail
Посмотреть сообщение
Is there a specific reason you're storing those as strings and not as integers?
He wants to use them as the TextDraws' text.

[ ----- ]

PHP код:
new wh_alert_seconds[2], wh_seconds[2]; 
I just noticed those, set the cell amount to 3 if you want up to a two digit number.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)