AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Add Leading Zero (https://forums.alliedmods.net/showthread.php?t=86112)

Mlk27 02-20-2009 22:28

Add Leading Zero
 
Any idea how to add leading zero if an integer has only 1 digit

Code:
public Check_Uptime() {     new Float:ft = Float:engfunc(EngFunc_Time)     new it = floatround(ft)     new s = it % 60;     new m = (it / 60) % 60     new h = (it / 3600) % 24     new d = it / 86400     format(Curr_Uptime, 16, "%i:%i:%i:%i", d, h, m, s)     set_cvar_string("Current_Uptime", Curr_Uptime) }

Current_Uptime : 9:3:9:9 => 09:03:09:09

YamiKaitou 02-20-2009 22:34

Re: Add Leading Zero
 
I believe %02i will work for you

Mlk27 02-21-2009 01:00

Re: Add Leading Zero
 
yeah that works..thanks :)


All times are GMT -4. The time now is 17:04.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.