For the complete documentation index, see llms.txt. This page is also available as Markdown.

Business Taxes Integration


Read carefully!

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

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 company 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_taxijob

esx_taxijob
RegisterNetEvent('esx_taxijob:success', function()
    local xPlayer = ESX.GetPlayerFromId(source)
    local timeNow = os.clock()
    
    if xPlayer.job.name ~= 'taxi' then
        print(('[^3WARNING^7] Player ^5%s^7 attempted to ^5esx_taxijob:success^7 (cheating)'):format(source))
        return
    end

    if not lastPlayerSuccess[source] or timeNow - lastPlayerSuccess[source] > 5 then
        lastPlayerSuccess[source] = timeNow

        local total = math.random(Config.NPCJobEarnings.min, Config.NPCJobEarnings.max)

        if xPlayer.job.grade >= 3 then
            total = total * 2
        end


        -- VMS City Hall & VMS Boss Menu - Business Taxes Integration --
        -- VMS City Hall & VMS Boss Menu - Business Taxes Integration --
        
        local society = exports['vms_bossmenu']:getSociety('taxi')
        if society then -- We check whether the "taxi" company is registered.
            -- If the company is registered, we continue to work with the company and taxes
            local playerMoney = ESX.Math.Round(total / 100 * 30)
            local societyMoney = ESX.Math.Round(total / 100 * 70)
            
            xPlayer.addMoney(playerMoney, "Taxi Fair")
            
            exports['vms_bossmenu']:addMoney('taxi', societyMoney, function()
                -- After adding money for the company, we add tax:
                exports['vms_cityhall']:addCompanyCustomTaxAmount(
                    'taxi', -- Job Name
                    total, -- Total amount
                    8 -- For example, 8% of the amount of total amount is additional tax
                )
            end)
            
            xPlayer.showNotification(TranslateCap('comp_earned', societyMoney, playerMoney))
        else
            xPlayer.addMoney(total, "Taxi Fair")
            xPlayer.showNotification(TranslateCap('have_earned', total))
        end
        
        -- VMS City Hall & VMS Boss Menu - Business Taxes Integration --
        -- VMS City Hall & VMS Boss Menu - Business Taxes Integration --
    end
end)

Last updated