[Help!]Ratio - 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: [Help!]Ratio (
/showthread.php?tid=315037)
[Help!]Ratio -
Zhoom - 01.02.2012
hey guys, how can i make a ratio on my website(top list)? i'm using tkadmin right now..
i tried this code:
pawn Код:
$ratio = $row['kills'] / $row['deaths'];
and a big failed
help me plox
Re: [Help!]Ratio -
Zhoom - 02.02.2012
nvm, i figured it out.
btw, i've a new problem!
for example, i've 630 kills and 162 deaths and my ratio is : 3.8888888888889
that was an epic number and my question is, how can i make it become 2 decimal point for example: 3.88?
this is my code:
Код:
if ($row['deaths'] == 0) { $ratio1 = $row['kills']; } else { $ratio1 = $row['kills'] / $row['deaths']; }
Re: [Help!]Ratio -
Niko_boy - 02.02.2012
Though i am not a pr0 / i dont even know, PHP , but a friend of mine once showed me a way to get selected Numbers/words or wtever from a string
it was some thing
preg_match or else i dont rember
I only know this hope u get any idea :/
Re: [Help!]Ratio -
Blacklite - 02.02.2012
http://php.net/manual/en/function.round.php
Check out the examples there.
Re: [Help!]Ratio -
Zhoom - 03.02.2012
ok, i read all of it, i tried and still failed
can you add it to this code please:
pawn Код:
if ($row['deaths'] == 0) { $ratio1 = $row['kills']; } else { $ratio1 = $row['kills'] / $row['deaths']; }
well yea, im a noob in php :$
Re: [Help!]Ratio -
Zhoom - 03.02.2012
*bump
well I tried this one: <?php echo round($ratio1, 2) ?>
failed.
what's wrong with it? :/
Re: [Help!]Ratio -
Min - 03.02.2012
Код:
if ($row['deaths'] == 0) { $ratio1 = $row['kills']; } else { $ratio1 = round($tkills1 / $deaths1 , 2); }
This should work.
Re: [Help!]Ratio -
Zhoom - 03.02.2012
WOW!
thx a lot!! it work