Working out percentages and stuff. - 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: Working out percentages and stuff. (
/showthread.php?tid=84722)
Working out percentages and stuff. -
Outbreak - 02.07.2009
Hi, im really confused with working out percentages.
This is what i've tried so far, but went horrible wrong.
pawn Код:
new percent = 3; //3 percent
new Float:earned = PropData[propertyid][p_Sell] - ((PropData[propertyid][p_Sell] / 100.0) * percent);
I end up getting some crazy long number.. Can someone help with this please?
Re: Working out percentages and stuff. -
Ignas1337 - 02.07.2009
hmm, i'll check this out. i'll edit this post
pawn Код:
new float:proc = 0.97; // note that this will be equal to the amount remaining ;]
new earned = floatround(PropDate[propertyid][p_Sell]*proc); // this will round the float. there may be a slight miscalculation at some points for example *.5 at the end would lead it would be *+1 instead of *1, but tat's nothing to worry about. this should work. wtf am I writing so long anyway? :DD
Re: Working out percentages and stuff. -
BMUK - 02.07.2009
Код:
forward Percent(Float:number, Float:percentage);
Код:
stock Percent(Float:number, Float:percentage) {
new Float:Sum;
Sum = (number/100)*percentage;
return floatround(Sum);
}
Код:
new wages = Percent(number,percentage);
Re: Working out percentages and stuff. -
Outbreak - 02.07.2009
Thanks guys, helped a lot. I've got it working perfect now.
Again thanks for your time and replies