Signcheck 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)
+--- Thread: Signcheck help needed (
/showthread.php?tid=455555)
Signcheck help needed -
Songason - 02.08.2013
When players do /signcheck they get a huge tax interest or something of like -$17343424442 wich makes you poor right away. This happens at every /signcheck
Код:
SendPayCheck(i)
{
new account,cash,interest;
new tmpintrate = 1; //interest rate
account = PlayerInfo[i][pAccount]; //bank account amount
cash = PlayerInfo[i][pCash];
if(PlayerInfo[i][pPayDay] >= 5)
{
new checks = PlayerInfo[i][pPayCheck]; //paycheck amount
new incometax = PlayerInfo[i][pPayCheck] / 100 * Tax; //income tax amount
GiveMoney(i,); //give money
//TAX MONEY
TaxValue = TaxValue+incometax;
//ELECTRICITY
new ebill = 0;
if(PlayerInfo[i][pHouseID] != 0)
{ //owns house
new randomv = random(1000);
ebill += (randomv*HouseInfo[PlayerInfo[i][pHouseID]][hLevel])/2;
}
if(PlayerInfo[i][pBizKey] != -1)
{ //owns business
new bizkey = PlayerInfo[i][pBizKey];
ebill += (BizInfo[bizkey][bTill])/4;
}
interest = (PlayerInfo[i][pAccount]/1000)*(tmpintrate); //interest
PlayerInfo[i][pAccount] = account+interest; //add interest money to bank
PlayerInfo[i][pExp]++;
SendClientMessage(i, COLOR_WHITE, "|___ BANK STATEMENT ___|");
format(string, sizeof(string), " Paycheck: $%d", checks);
SendClientMessage(i, COLOR_GRAD1, string);
format(string, sizeof(string), " Income Tax: -$%d", incometax);
SendClientMessage(i, COLOR_GRAD1, string);
if(PlayerInfo[i][pBizKey] != -1 || PlayerInfo[i][pHouseID] != 0)
{ //owns house or business
GiveMoney(i,-ebill);
format(string, sizeof(string), " Electricity Bill: -$%d", ebill);
SendClientMessage(i, COLOR_GRAD1, string);
}
format(string, sizeof(string), " Interest Rate: 0.%d percent",tmpintrate);
SendClientMessage(i, COLOR_GRAD2, string);
format(string, sizeof(string), " Interest Gained $%d", interest);
SendClientMessage(i, COLOR_GRAD2, string);
SendClientMessage(i, COLOR_GRAD4, "|------------------------------------------|");
format(string, sizeof(string), " Old Balance: $%d", account);
SendClientMessage(i, COLOR_GRAD5, string);
format(string, sizeof(string), " Old Cash: $%d", cash);
SendClientMessage(i, COLOR_GRAD5, string);
format(string, sizeof(string), " New Balance: $%d", PlayerInfo[i][pAccount]);
SendClientMessage(i, COLOR_GRAD5, string);
PlayerInfo[i][pCheck] = 0;
PlayerInfo[i][pPayDay] = 0;
PlayerInfo[i][pPayCheck] = 0;
}
else
{
PlayerInfo[i][pCheck] = 0;
PlayerInfo[i][pPayDay] = 0;
PlayerInfo[i][pPayCheck] = 0;
SendClientMessage(i, COLOR_LIGHTRED, "* You haven't played long enough to obtain a Paycheck.");
}
return 1;
}
Re: Signcheck help needed -
Songason - 02.08.2013
Bump please please help
Re: Signcheck help needed -
Vince - 02.08.2013
Use brackets if unsure about the order of operators. This:
pawn Код:
PlayerInfo[i][pPayCheck] / 100 * Tax;
Will most likely compile as:
pawn Код:
PlayerInfo[i][pPayCheck] / (100 * Tax);
If your tax is is, say, 10% then you will divide the player's money by 1000 instead of taking 10%.
Though that's probably not the only problem. You'll have to carefully examine each calculation.
AW: Signcheck help needed -
Nero_3D - 02.08.2013
Post the whole code with GiveMoney and values of
Tax and
TaxValue
@Vince The compiler knows the mathematical rules and calculates that from left to right resulting in 0 because pPayDay is likely below 100