Using percentages in Pawn - 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: Using percentages in Pawn (
/showthread.php?tid=243706)
Using percentages in Pawn -
mrcoolballs - 24.03.2011
Hey, I have developed my own tax script, which I have been using for many months now, and I decided I want to step it up.
This is it right now.
pawn Код:
public TaxTimer(playerid)
{
if(GetPlayerMoney(playerid) <= 100) return 0;
new amount = GetPlayerMoney(playerid)/6;
GivePlayerMoney(playerid,-amount);
new str[40];
format(str,sizeof(str),"You have paid $%d in tax",amount);
SendClientMessage(playerid,0xFF0000FF,str);
return 1;
}
Pretty much all that does, is divides the players current cash by 6, and charges them the result in tax.
It's a simple idea, but I want to step it up, I'm thinking of creating a tax-rate in percentage.
Does anyone know if that is possible?
What I mean is that it would be something like 23% of the players current money would be charged.
I know dividing it by four would be equal to 25 %.
Is it possible to do anything like, "GetPlayerMoney(playerid)/23%"
If this is possible I will try and set up a command, "/setrate <percentage>".
If anyone can understand what I'm asking it would be very helpful for an answer.
Re: Using percentages in Pawn -
Mike_Peterson - 24.03.2011
To calculate the amount e.g.: u want 30% of player's money and player would had 1000$. that would be 300$ to calculate that. use 1000 / 100 * percent. its easy.
1000 / 100 = 10 x 30 = 300 aka 300$