SA-MP Forums Archive
00:00 with ternary operator ? - 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: 00:00 with ternary operator ? (/showthread.php?tid=484045)



00:00 with ternary operator ? - erminpr0 - 28.12.2013

So gettime function returns hrs/mins/secs as '0', not 00.
It's easy to format string many times and check if hrs > 0 & < 9 (same with mins)
but how to make with ternary operator, if hrs/mins < 10 it would be ex.

04:32
07:01

and not

4:32
7:1

My /time command, please help REP+
pawn Code:
YCMD:time(playerid, params[], help)
{
    #pragma unused help
    #pragma unused params
    new hrs,mins,sec,day,month,year;
    gettime(hrs, mins, sec);
    getdate(year, moth, day);
    new string[45];
    format(string, sizeof(string), "Today is: %d. %d. %d | Current Time: %d:%d", day, month, year, hrs, mins);
    return SendClientMessage(playerid, -1, string);
}



Re: 00:00 with ternary operator ? - Konstantinos - 28.12.2013

pawn Code:
format(string, sizeof(string), "Today is: %d. %d. %d | Current Time: %02d:%02d", day, month, year, hrs, mins);