Property Taxes - 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: Property Taxes (
/showthread.php?tid=657573)
Property Taxes -
ServerFiles - 10.08.2018
Hi guys, I'm sorry but I'm newbie and just learned how to code.
My question is,
How can I create a tax system for every property he owns?
For example
Default tax for biz is $1000
Every pay time he must pay $1k to government
and if he owns 2 biz, then he must pay $2k and so on.
Re: Property Taxes -
TVDude - 11.08.2018
Make a global timer (or player timer that starts when the player connects/logs in) that goes off every hour or whatever interval you want it to go off at and place something like this in the code:
pawn Код:
forward PaycheckTimerFunction();
public PaycheckTimerFunction()
{
for(new i=0, j=GetPlayerPoolSize(); i<=j; i++) //player loop if you go the global timer route, which this function is
{
if(IsPlayerConnected(i)) //is the playerid connected?
{
if(statement checks) //this is where you check if the player has a business
{
new total = GetTotalPlayerBusinessCount(i); //GetTotalPlayerBusinessCount would be where you calculate how many businesses the player owns
new tax = total*1000; //total tax amount to be taken away
GivePlayerMoney(i,-tax); //removes the necessary amount of money
}
}
}
}
Re: Property Taxes -
Sew_Sumi - 11.08.2018
There's more to this than the above simple 'throw out an answer' scenario.
There'd be an idea that even though the player is offline, the business can still be operating, so it wouldn't as much be based on the player pool, it would be more on a business loop, taking from their till and paying the bank.
You could use the above throw-out (Even though I wouldn't trust the formula at all), and modify it to handle the businesses as the loop, and make the businesses payout in that time, to the bank.