Hi i am having trouble creating a Economy script that loops through each players bank accounts also there holding amount and removes a amount of taxes depending on there Gross Wealth..
Nothing seams to be happening, It compiles but well i guess its not working..
pawn Код:
//OnPlayerConnect..
SetTimerEx("ServerEconomy", 240000, true, "d", playerid);
//code..
public ServerEconomy(playerid)
{
new string[128], pName[64], file[150];
new GetHoldingGrossAmount;
new GetBankGrossAmount;
new SetNetAmount1;
new SetNetAmount2;
format(file, sizeof(file), BANK_FILE, pName);
GetPlayerName(playerid, (pName), sizeof(pName));
GetHoldingGrossAmount = GetPlayerCash(playerid)/GetPVarInt(playerid,"5");
GetBankGrossAmount = dini_Int(file, "Balance")/GetPVarInt(playerid,"5");
SetNetAmount2 = GetHoldingGrossAmount && GetBankGrossAmount;
SetNetAmount1 = GetHoldingGrossAmount;
if(GetPlayerCash(playerid) < 10000) return GivePlayerCash(playerid,10000) && SendClientMessage(playerid, LIGHTGREEN, "[Payday]: You Have Recieved $10,000 From The Welfare Department!");
if(PlayerInfo[playerid][vLevel] >= 1) return 0;//VIPs bypass Taxes..
else if(dini_Exists(file) && GetHoldingGrossAmount && GetBankGrossAmount > 10000)
{
GivePlayerCash(playerid,-SetNetAmount2);
format(string,sizeof(string),"[Taxes]: %s [%d] Has Just Paid $%i In General Taxes!", pName, playerid, SetNetAmount2);
SendClientMessageToAll(RED, string);
}
else if(GetHoldingGrossAmount > 10000)
{
GivePlayerCash(playerid,-SetNetAmount1);
format(string,sizeof(string),"[Taxes]: %s [%d] Has Just Paid $%i In General Taxes!", pName, playerid, SetNetAmount1);
SendClientMessageToAll(RED, string);
}
else if(GetHoldingGrossAmount > 100000)
{
GivePlayerCash(playerid,-SetNetAmount1);
format(string,sizeof(string),"[Taxes]: %s [%d] Has Just Paid $%i In Wealth Taxes!", SetNetAmount1);
SendClientMessageToAll(RED, string);
}
else if(dini_Exists(file) && GetHoldingGrossAmount && GetBankGrossAmount > 100000)
{
GivePlayerCash(playerid,-SetNetAmount2);
format(string,sizeof(string),"[Taxes]: %s [%d] Has Just Paid $%i In Wealth Taxes!", SetNetAmount2);
SendClientMessageToAll(RED, string);
}
return 1;
}
pawn Код:
#define TAX_RATE 0.33
forward PlayerPayTax(playerid);
public PlayerPayTax(playerid)
{
new Tax = GetPlayerMoney(playerid) * TAX_RATE / 100;
GivePlayerMoney(playerid, -Tax);
format(string,sizeof(string),"[Taxes]: %s [%d] Has Just Paid $%i In General Taxes!", GetPlayerNameEx(playerid), playerid, Tax);
SendClientMessageToAll(RED, string);
}
stock GetPlayerNameEx(playerid)
{
new pName[24];
GetPlayerName(playerid, pName, sizeof(pName));
return pName;
}