AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Calculating, k/d ratio. (https://forums.alliedmods.net/showthread.php?t=189666)

Santaaa 07-09-2012 17:37

Calculating, k/d ratio.
 
Hello there,

For example someone has a 1.41 k/d ratio and he will unlock an achievement with a 1.50 k/d ratio how will I check if the user has a 1.50 k/d ratio?

Exolent[jNr] 07-09-2012 17:43

Re: Calculating, k/d ratio.
 
deaths = get deaths
if deaths is 0, deaths = 1
ratio = get frags / deaths
if ratio is greater than or equal to 1.5, then give achievment

Santaaa 07-09-2012 17:47

Re: Calculating, k/d ratio.
 
Yea, my question was how will i check if its higher then 1,5?

Can i just use for example if (Ratio >= 1.5)

Exolent[jNr] 07-09-2012 17:51

Re: Calculating, k/d ratio.
 
Compiling and testing do wonders.

Santaaa 07-09-2012 17:53

Re: Calculating, k/d ratio.
 
does it need 2 decimals?

Doc-Holiday 07-09-2012 18:44

Re: Calculating, k/d ratio.
 
Quote:

Originally Posted by Santaaa (Post 1746921)
does it need 2 decimals?

two decimals??

1..5?

Bugsy 07-09-2012 19:08

Re: Calculating, k/d ratio.
 
Use floats in the equation, if that's what you meant.

isotonic 07-09-2012 19:56

Re: Calculating, k/d ratio.
 
PHP Code:

new Float:ratio
ratio 
get frags deaths
if ( ratio >= 1.5 ) { 

Only floats could have fractional part.

Bugsy 07-09-2012 21:01

Re: Calculating, k/d ratio.
 
PHP Code:

new Float:fRatio = ( floatget_user_fragsid ) ) / floatget_user_deathsid ) ) );
if ( 
fRatio >= 1.5 
{
        



Santaaa 07-09-2012 21:19

Re: Calculating, k/d ratio.
 
Yea, I used a FLOAT for my calculation, but I didnt know that it will catch the ratio's number like on this way :P


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

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