Personal Taxes Integration


The following tax integration example is based on the publicly available resource esx_property.

After reviewing and carefully reading this guide, you'll understand how to implement the tax system into other resources as well.

Please note that implementation is only possible in open-source resources - it's not possible to introduce functional taxation in escrow-protected scripts. In such cases, we recommend contacting the author of the resource and requesting compatibility with our system.

Source Code: https://github.com/esx-framework/esx_property

esx_property
ESX.RegisterServerCallback("esx_property:buyProperty", function(source, cb, PropertyId)
  local xPlayer = ESX.GetPlayerFromId(source)
  local Price = Properties[PropertyId].Price
  if xPlayer.getAccount("bank").money >= Price then
    xPlayer.removeAccountMoney("bank", Price, "Bought Property")
    
    -- VMS City Hall - Personal Taxes Integration --
    -- VMS City Hall - Personal Taxes Integration --
    
    exports['vms_cityhall']:addPlayerCustomTaxToPay(
      xPlayer.identifier, -- Player Identifier like steam hex/ rockstar license or citizenid for qb-core
      Price, -- The price on which the tax is to be calculated
      15, -- For example, 15% of the amount of property is additional tax
      "Property Purchase TAX" -- Tax title visible in city hall menu
    )
    
    -- VMS City Hall - Personal Taxes Integration --
    -- VMS City Hall - Personal Taxes Integration --
    
    Properties[PropertyId].Owner = xPlayer.identifier
    Properties[PropertyId].OwnerName = xPlayer.getName()
    Properties[PropertyId].Owned = true
    Log("Property Bought", 65280, {{name = "**Property Name**", value = Properties[PropertyId].Name, inline = true},
                                   {name = "**Price**", value = ESX.Math.GroupDigits(Price), inline = true},
                                   {name = "**Player**", value = xPlayer.getName(), inline = true}}, 1)
    TriggerClientEvent("esx_property:syncProperties", -1, Properties)
    if Config.OxInventory then
      exports.ox_inventory:RegisterStash("property-" .. PropertyId, Properties[PropertyId].Name, 15, 100000, xPlayer.identifier)
    end
  end
  cb(xPlayer.getAccount("bank").money >= Price)
end)

Last updated

Was this helpful?