09.01.2016, 15:50
Hello there,
I've been working on a paycheck script and I want to give a user a certain percentage interest on his balance when a paycheck happens.
With a start bank balance of 10000 the script works 2 times. With a percentage of 1% the player will get 100 on his first paycheck, and then 101. But after that; the server keeps giving 101 interest.
My guess is that the interest integer tries to get 1% of 10201 which then fails since it has multiple decimals.
How can I fix this problem?
I've been working on a paycheck script and I want to give a user a certain percentage interest on his balance when a paycheck happens.
With a start bank balance of 10000 the script works 2 times. With a percentage of 1% the player will get 100 on his first paycheck, and then 101. But after that; the server keeps giving 101 interest.
My guess is that the interest integer tries to get 1% of 10201 which then fails since it has multiple decimals.
How can I fix this problem?
PHP код:
if(Player[playerid][pBank] > 0)
{
new interest, newBank;
newBank = ((Player[playerid][pBank] / 100) * (100 + BANK_DEFAULT_INTEREST));
interest = newBank - Player[playerid][pBank];
SendClientMessageEx(playerid, -1, "Your old balance is %d.", Player[playerid][pBank]);
SendClientMessageEx(playerid, -1, "Your balance interest is %d percent, which gives you %d.", BANK_DEFAULT_INTEREST, interest);
SendClientMessageEx(playerid, COLOR_SUCCESS, "Your new balance is %d.", newBank);
Player[playerid][pBank] = newBank;
}