Huge bug - help needed.
#1

Problem with this - it gives you roughly 1 billion per payday.. I've NO idea how, and the only place it shows that is in the Closing Balance.

Any help is greatly appreciated.

pawn Код:
public Payday(playerid)
{
    if(PlayerInfo[playerid][pPaydayTime] >= 60 && gPlayerLogged[playerid] == 1)
    {
        new job[15];
        strmid(job, GetJobNameFromID(PlayerInfo[playerid][pJob]), 0, strlen(GetJobNameFromID(PlayerInfo[playerid][pJob])), 255);
       
        PlayerInfo[playerid][pTotalPlay] ++;
        if(PlayerInfo[playerid][pJobContract] > 0) PlayerInfo[playerid][pJobContract]--;
       
        new Float:interest = PlayerInfo[playerid][pBank] * 0.01;
        new house = IsPlayerRentingHouse(playerid);
        new faction = PlayerInfo[playerid][pFaction];
        new rank = PlayerInfo[playerid][pRank];
       
        if(PlayerInfo[playerid][pPayday] > 1500 && (PlayerInfo[playerid][pJob] == JOB_TRASH || PlayerInfo[playerid][pJob] == JOB_SWEEPER)) PlayerInfo[playerid][pPayday] = 1500;
        SendClientMessage(playerid, COLOR_WHITE, "{FF0000}|____________________{FFFFFF}Bank Statement{FF0000}____________________|");
        SendFormattedMessage(playerid, COLOR_WHITE, "Opening Balance: {00DC1D}$%d", PlayerInfo[playerid][pBank]);
       
        PlayerInfo[playerid][pBank] += PlayerInfo[playerid][pPayday];
        PlayerInfo[playerid][pBank] += interest;
       
        SendFormattedMessage(playerid, COLOR_WHITE, "Job: %s | Job Pay: +{00DC1D}$%d", job, PlayerInfo[playerid][pPayday]);
       
        if(PlayerInfo[playerid][pFaction] > 0) {
            PlayerInfo[playerid][pBank] += RankInfo[faction][rank-1][rWage];
            SendFormattedMessage(playerid, COLOR_WHITE, "Faction: %s | Wage Pay: +{00DC1D}$%d", GetFactionNameFromID(faction), RankInfo[faction][rank-1][rWage]); // FACTION WAGE
        }
       
        SendFormattedMessage(playerid, COLOR_WHITE, "Interest: +{00DC1D}$%.0f", interest)
        ;
        if(house != 0) {
            if((PlayerInfo[playerid][pBank] - HouseInfo[house][hRentPrice]) > 0) {
                SendFormattedMessage(playerid, COLOR_WHITE, "Rent: -{00DC1D}$%d", HouseInfo[house][hRentPrice]);
                PlayerInfo[playerid][pBank] -= HouseInfo[house][hRentPrice];
                if(PlayerInfo[playerid][pRentTime] > 0) PlayerInfo[playerid][pRentTime] --;
            }
            else {
                SendClientMessage(playerid, COLOR_WHITE, "Rent: Unable to pay. You've been evicted.");
                EvictPlayer(playerid);
            }
        }
       
        PlayerInfo[playerid][pTotalPay] += PlayerInfo[playerid][pPayday];
        PlayerInfo[playerid][pPayday] = 0;
        PlayerInfo[playerid][pPaydayTime] = 0;
        SendFormattedMessage(playerid, COLOR_WHITE, "Closing Balance: {00DC1D}$%d", PlayerInfo[playerid][pBank]);
        SendClientMessage(playerid, COLOR_WHITE, "{FF0000}____________________________________________________________");
        printf("Payday function called for playerid %d", playerid);
    }
    else if(PlayerInfo[playerid][pPaydayTime] < 60 && gPlayerLogged[playerid] == 1)
    {
        PlayerInfo[playerid][pPaydayTime] ++;
    }
    return 1;
}
Reply
#2

Where does it give the 1 mil? Because I have a payday system on my RP server and it works fine.
Reply
#3

I think it may be doing it on

PlayerInfo[playerid][pBank] += interest;

because 'interest' is a float, and rank is an int?
Reply
#4

try
Код:
PlayerInfo[playerid][pBank] += floatround(interest,floatround_floor);
Reply
#5

What type of rounding is floor?
Reply
#6

it simply truncates the float, so its just ignoring the values <1.00000.
you could use the https://sampwiki.blast.hk/wiki/Floatround_method "floatround_round", its the proper method for your payday
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)