Taxes house


#1

Hello, I have modified a script to make people paye at each payday taxes on their house if they are owner of a house, but it seem to make them pay their house price multiplicated by the number of player online in the server, moreover player without house paye the taxes when they don’t own them :confused: I don’t understand why, can someone help me please

My modified code of ESX:

function PayRent()

	local xPlayers = ESX.GetPlayers()
	for i=1, #xPlayers, 1 do
     local xPlayer = ESX.GetPlayerFromId(xPlayers[i])  
	 
      MySQL.Async.fetchAll(
        'SELECT * FROM owned_properties WHERE rented = 1 AND owner="'.. xPlayer.identifier ..'"',
        {},
        function(result)

          for i=1, #result, 1 do
			if xPlayer.identifier == result[i].owner then
              xPlayer.removeAccountMoney('bank', result[i].price)
			  TriggerClientEvent('esx:showNotification', xPlayer.source, ('~o~Taxe') .. '\n~s~Maison: ~r~-$'.. result[i].price)

            TriggerEvent('esx_addonaccount:getSharedAccount', 'society_realestateagent', function(account)
              account.addMoney(result[i].price)
            end)
			end

          end
		  end
      )
	  end

    end

#2

Sounds like a realistic thing. Similar to how we pay taxes here in NYC.


#3

Hello mate, your idea is great for the rent… Did u managed to make it work ? If yes i would appreciate if you can post script with the fix because its simple and great and i like work like that.


#4

Yes I have done this, I send u the code when I’m at house :slight_smile:


#5

Thank you sir, i appreciate this alot, there is not alot of people like you which wanna help others. Thank you again man !


#6

Try change this:

 MySQL.Async.fetchAll(
        'SELECT * FROM owned_properties WHERE rented = 1 AND owner="'.. xPlayer.identifier ..'"',
        {},

To:

MySQL.Async.fetchAll(
        'SELECT * FROM owned_properties WHERE rented = 1 AND owner = @owner',
        {
		    ['@owner'] = xPlayer.identifier
		},

#7

Hello, is the code still available?
PS: Is this possible with cars? (tax)

Find your script super: D


#8

Yes I have always the script, if you want I give you it when I can, and yes it’s possible make it for cars :wink:


#9

Anyway i can have it as Well? Looks Good :slight_smile:


#10

Yes, I would be very happy
: D


#11

If I remember correctly (Because there is like 2 months I stopped the dev of my server) you have to go in es_extended (with ESX) -> server -> paycheck_company.lua

And replace all the code by this:

ESX.StartPayCheck = function ()

  function payCheck ()
    local xPlayers = ESX.GetPlayers()
    for i=1, #xPlayers, 1 do
      local xPlayer = ESX.GetPlayerFromId(xPlayers[i])
      if xPlayer.job.grade_name == 'interim' or xPlayer.job.grade_name == 'rsa' or xPlayer.job.grade_name == 'employee' then -- Si il n'est pas dans une société, je prends chez l'état
        if xPlayer.job.grade_salary >= 0 then
          xPlayer.addAccountMoney('bank',xPlayer.job.grade_salary)
          local interetsNoSociete = xPlayer.getAccount('bank').money*0.0020
		  xPlayer.addAccountMoney('bank',tonumber(string.format("%.2f", interetsNoSociete)))
		  
          TriggerClientEvent('esx:showNotification', xPlayer.source, ('~b~Paye du jour') .. '\n~s~Salaire: ~g~$'.. xPlayer.job.grade_salary ..'\n~s~Intérêts ~s~(~g~0.20%~s~): ~g~$' .. tonumber(string.format("%.2f", interetsNoSociete)))
        MySQL.Async.fetchAll(
        'SELECT * FROM owned_properties WHERE rented = 1 AND owner="'.. xPlayer.identifier ..'"',
        {},
		function(result)

          for i=1, #result, 1 do
			if xPlayer.identifier == result[i].owner then
              xPlayer.removeAccountMoney('bank', result[i].price)
			  TriggerClientEvent('esx:showNotification', xPlayer.source, ('~o~Taxe') .. '\n~s~Maison: ~r~-$'.. result[i].price)

            TriggerEvent('esx_addonaccount:getSharedAccount', 'society_realestateagent', function(account)
              account.addMoney(result[i].price)
            end)
			end

          end
		  end
		)
		end
      else -- Sinon je prends l'argent dans la société
        TriggerEvent('esx_society:getSociety', xPlayer.job.name, function (society)
          TriggerEvent('esx_addonaccount:getSharedAccount', society.account, function (account)
        if account.money >= xPlayer.job.grade_salary then
          xPlayer.addAccountMoney('bank',xPlayer.job.grade_salary)
          account.removeMoney(xPlayer.job.grade_salary)
		  
		  local interets = xPlayer.getAccount('bank').money*0.0020
		  xPlayer.addAccountMoney('bank',tonumber(string.format("%.2f", interets)))
		  
          TriggerClientEvent('esx:showNotification', xPlayer.source, ('~b~Paye du jour') .. '\n~s~Salaire: ~g~$'.. xPlayer.job.grade_salary ..'\n~s~Intérêts ~s~(~g~0.20%~s~): ~g~$' .. tonumber(string.format("%.2f", interets)))
		  MySQL.Async.fetchAll(
          'SELECT * FROM owned_properties WHERE rented = 1 AND owner="'.. xPlayer.identifier ..'"',
          {},
		  function(result)

          for i=1, #result, 1 do
			if xPlayer.identifier == result[i].owner then
              xPlayer.removeAccountMoney('bank', result[i].price)
			  TriggerClientEvent('esx:showNotification', xPlayer.source, ('~o~Taxe') .. '\n~s~Maison: ~r~-$'.. result[i].price)

            TriggerEvent('esx_addonaccount:getSharedAccount', 'society_realestateagent', function(account)
              account.addMoney(result[i].price)
            end)
			end

          end
		  end
		)
        else
          local interets2 = xPlayer.getAccount('bank').money*0.0020
		  xPlayer.addAccountMoney('bank',tonumber(string.format("%.2f", interets2)))
		  
          TriggerClientEvent('esx:showNotification', xPlayer.source, ('~o~Société sans fond') .. '\n~s~Salaire: ~g~$0\n~s~Intérêts ~s~(~g~0.20%~s~): ~g~$' .. tonumber(string.format("%.2f", interets2)))
		  
		MySQL.Async.fetchAll(
        'SELECT * FROM owned_properties WHERE rented = 1 AND owner="'.. xPlayer.identifier ..'"',
        {},
        function(result)

          for i=1, #result, 1 do
			if xPlayer.identifier == result[i].owner then
              xPlayer.removeAccountMoney('bank', result[i].price)
			  TriggerClientEvent('esx:showNotification', xPlayer.source, ('~o~Taxe') .. '\n~s~Maison: ~r~-$'.. result[i].price)

            TriggerEvent('esx_addonaccount:getSharedAccount', 'society_realestateagent', function(account)
              account.addMoney(result[i].price)
            end)
			end

          end
		  end
		)
		end
      end)
      end)
    end
    end

    SetTimeout(Config.PaycheckInterval, payCheck)
  end
  SetTimeout(Config.PaycheckInterval, payCheck)
end

And in esx_property -> server -> main.lua delete the line 577:

TriggerEvent('cron:runAt', 22, 0, PayRent)

PS: If you want to change the percentage of interest just change:
local interetsNoSociete = xPlayer.getAccount('bank').money*0.0020
local interets = xPlayer.getAccount('bank').money*0.0020
local interets2 = xPlayer.getAccount('bank').money*0.0020

0.0020 = 0.20% of interest on the bank account.


#12

The taxes on vehicles is not here, but I will code it monday if you really need it, because this weekend I’m not at home, I hope this will help you in the developpement of your server good luck, for those who want all my resources to maybe add some of my other custom modifications, or script I have made for me like the pound managed by the mechanics society.


#13

thank you so much :slight_smile:


#14

Thank you a very good script
is good for the state money: D


#15

Have you ever
written

vehicle tax ???

I would be very happy


#16

Hey Ciwiel,

i read that you created a tax system, for homes and you had the opinion for vehicles is it possible to show or to share how you did that, it’s amazing what youve done.
Thank you so much for your help,


#17

If you want, that the gamer PAY the Taxes change that Line to
local interetsNoSociete = xPlayer.getAccount(‘bank’).money*(-0.0020)

GreetZ


#18

[NEED HELP]
Error running call reference function for resource es_extended: citizen:/scripting/lua/scheduler.lua:351: server/paycheck_company.lua:35: attempt to index a nil value (local ‘society’)

Think the error comes, because one society is = 0 (empty) right? @Ciwiel


#19

@Ciwiel reading meassages? there is a problem if the money = 0.


#20

Check in ur database if u have society_realestateagent in addon_account, addon_account_data