Using percentages in Pawn
#1

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.
Reply
#2

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$
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)