Huge bug - help needed. - 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: Huge bug - help needed. (
/showthread.php?tid=241451)
Huge bug - help needed. -
Antonio [G-RP] - 18.03.2011
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;
}
Re: Huge bug - help needed. -
Tee - 18.03.2011
Where does it give the 1 mil? Because I have a payday system on my RP server and it works fine.
Re: Huge bug - help needed. -
Antonio [G-RP] - 18.03.2011
I think it may be doing it on
PlayerInfo[playerid][pBank] += interest;
because 'interest' is a float, and rank is an int?
Re: Huge bug - help needed. -
Babul - 18.03.2011
try
Код:
PlayerInfo[playerid][pBank] += floatround(interest,floatround_floor);
Re: Huge bug - help needed. -
Antonio [G-RP] - 18.03.2011
What type of rounding is floor?
Re: Huge bug - help needed. -
Babul - 19.03.2011
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