Problem with integers and gettings percentages from them
#1

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?

PHP код:
if(Player[playerid][pBank] > 0)
    {
        new 
interestnewBank;
        
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_INTERESTinterest);
        
SendClientMessageEx(playeridCOLOR_SUCCESS"Your new balance is %d."newBank);
        
        
Player[playerid][pBank] = newBank;
        
    } 
Reply


Messages In This Thread
Problem with integers and gettings percentages from them - by Josh_Lotus - 09.01.2016, 15:50
Re: Problem with integers and gettings percentages from them - by Vince - 09.01.2016, 17:04
Re: Problem with integers and gettings percentages from them - by PrO.GameR - 09.01.2016, 21:40
Re: Problem with integers and gettings percentages from them - by Josh_Lotus - 09.01.2016, 23:07

Forum Jump:


Users browsing this thread: 2 Guest(s)