Signcheck help needed
#1

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;
}
Reply
#2

Bump please please help
Reply
#3

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.
Reply
#4

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
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)