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
		},