AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Hours in percentages (https://forums.alliedmods.net/showthread.php?t=189967)

Santaaa 07-13-2012 08:01

Hours in percentages
 
Hey,

How will I calculate the hours into percentages. I tryed:
PHP Code:

new hour get_user_time() / 3600
new percent hour 100 25 

Maybe its * 60 because a hour has 60 minutes? but I dont know.
But if i will do that i will come out on 60% max when the user has reached the max time. I want that it goes max to 100%

<VeCo> 07-13-2012 08:37

Re: Hours in percentages
 
PHP Code:

percent 100 * (value max_value

So it should be like this (if you want 3600 secs to be 100%):

PHP Code:

new percent 100 * (get_user_time(id) / 3600


Santaaa 07-13-2012 08:58

Re: Hours in percentages
 
Thats for 1 hour, now i want it for 25 hours.

Would i do it like this?
PHP Code:

new hour get_user_time() / 3600
new percent hour 100 25 


<VeCo> 07-13-2012 09:31

Re: Hours in percentages
 
25 hours are 3600 * 25 = 90000

So use:
PHP Code:

new percent floatround(100 * (get_user_time(id) / 90000.0)) 

Or if you want it with the "hour" variable:
PHP Code:

new Float:hour get_user_time(id) / 90000.0
new percent floatround(100 hour



All times are GMT -4. The time now is 15:16.

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