AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Need convert this value in time (https://forums.alliedmods.net/showthread.php?t=249708)

Xenone 10-10-2014 13:07

Need convert this value in time
 
How to convert this variable in the client_print format ?

PHP Code:

g_time[id] = 5400 // 1 hour 30 minutes

// convert the 5400 time
client_print(idprint_chat"You can use your bonus in hours:minutes:seconds"g_time[id])

// like this
client_print(idprint_chat"You can use your bonus in 01:30:00"g_time[id]) 

Sorry bad english :)

.Dare Devil. 10-10-2014 13:51

Re: Need convert this value in time
 
How about this?
PHP Code:

g_time[id] = 5400
new hms
g_time[id] / 3600
= (g_time[id] - (*3600)) / 60
=  (g_time[id] - (*60))
new 
s_h[4], s_m[4], s_s[4];
if( 
10 formats_hcharsmax(s_h), "%d")
else 
formats_hcharsmax(s_h), "0%d")

if( 
10 formats_scharsmax(s_s), "%d")
else 
formats_scharsmax(s_s), "0%d")

if( 
10 formats_mcharsmax(s_m), "%d")
else 
formats_mcharsmax(s_m), "0%d")

client_print(idprint_chat"You can use your bonus in %d:%d:%d"hms


NikKOo31 10-11-2014 14:17

Re: Need convert this value in time
 
From time.inc

Code:

get_time_length

Syntax

stock get_time_length(id, unitCnt, type, output[], outputLen)

http://amxmodx.org/api/time/get_time_length


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

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