Simple maths (percentage) - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Simple maths (percentage) (
/showthread.php?tid=276739)
Simple maths (percentage) -
MP2 - 15.08.2011
Okay it's 4AM so my brain is nowhere to be found. I have 2 variables; total_wins and my_wins. I want it to display to the player what percentage of wins are theirs. What maths do I need for this?
Re: Simple maths (percentage) -
dowster - 15.08.2011
(my_wins / total_wins) = percentage
Re: Simple maths (percentage) -
legodude - 15.08.2011
(my_wins / total_wins)*100 = percentage
that will get you a percentage.
Re: Simple maths (percentage) -
TouR - 15.08.2011
pawn Код:
floatround((my_wins / total_wins)*100, floatround_round);
You can also use this to prevent percentage be a float
Re: Simple maths (percentage) -
MP2 - 15.08.2011
When I do
(my_wins/total_wins)*100
it returns as 0...
Re: Simple maths (percentage) -
Lorenc_ - 15.08.2011
Are the variable stored correctly/used correctly?
Re: Simple maths (percentage) -
dowster - 15.08.2011
Try doing
(my_wins/total_wins*100) you may be getting errors having the *100 outside of the parenthesis, and also check what Lorenc_ said most likely it is the variables not being stored right.
Re: Simple maths (percentage) -
MP2 - 16.08.2011
I changed them to floats and it worked >.>