SA-MP Forums Archive
Number digits in time limit - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Number digits in time limit (/showthread.php?tid=362386)



Number digits in time limit - Killer#Mummy - 24.07.2012

Hello everyone!

I have a variable, which shows me time limit. I want to change it, so that all numbers are 2 characters long. (Damn my english)

Current look: TIME LEFT: 0:3:45
Wanted look: TIME LEFT: 00:03:45

How to do this?


Re: Number digits in time limit - Babul - 24.07.2012

you can format your variable to show the preceding zeros:
pawn Код:
format(string,sizeof(string),"TIME LEFT: %02d:%02d:%02d",hours,minutes,seconds);
if you want a number like 0003, use %04d or for 0001.001337, use %04.06f


Re: Number digits in time limit - Killer#Mummy - 24.07.2012

Thank you very much Babul! Its working