Installation

Add dependencies:

Add the script:

  1. Add the script into resources folder.

  2. Import dealers.sql into database.

  3. Start the script in server.cfg

Apply Modifications: (if you want to add new job with /adddealerjob)

Add this code at the bottom of "es_extended/server/common.lua"

RegisterNetEvent('esx:refreshJobs', function(cb, triggerCheck)
    if triggerCheck then
        triggerCheck(true)
        return
    end
    local Jobs = {}
    MySQL.Async.fetchAll('SELECT * FROM jobs', {}, function(jobs)
        for k, v in ipairs(jobs) do
            Jobs[v.name] = v
            Jobs[v.name].grades = {}
        end
        MySQL.Async.fetchAll('SELECT * FROM job_grades', {}, function(jobGrades)
            for k, v in ipairs(jobGrades) do
                if Jobs[v.job_name] then
                    Jobs[v.job_name].grades[tostring(v.grade)] = v
                end
            end
            for k2, v2 in pairs(Jobs) do
                if ESX.Table.SizeOf(v2.grades) == 0 then
                    Jobs[v2.name] = nil
                end
            end
            ESX.Jobs = Jobs
            if cb then
                cb(true)
            end
        end)
    end)
end)

Add this code at the bottom of "esx_addonaccount/server/main.lua"

RegisterNetEvent('esx_addonaccount:refreshAccounts', function(cb, triggerCheck)
	if triggerCheck then
		triggerCheck(true)
		return
	end
	AccountsIndex, Accounts, SharedAccounts = {}, {}, {}
	local result = MySQL.Sync.fetchAll('SELECT * FROM addon_account')
	for i=1, #result, 1 do
		local name   = result[i].name
		local label  = result[i].label
		local shared = result[i].shared
		local result2 = MySQL.Sync.fetchAll('SELECT * FROM addon_account_data WHERE account_name = @account_name', {
			['@account_name'] = name
		})
		if shared == 0 then
			table.insert(AccountsIndex, name)
			Accounts[name] = {}
			for j=1, #result2, 1 do
				local addonAccount = CreateAddonAccount(name, result2[j].owner, result2[j].money)
				table.insert(Accounts[name], addonAccount)
			end
		else
			local money = nil
			if #result2 == 0 then
				MySQL.Sync.execute('INSERT INTO addon_account_data (account_name, money, owner) VALUES (@account_name, @money, NULL)', {
					['@account_name'] = name,
					['@money']        = 0
				})
				money = 0
			else
				money = result2[1].money
			end
			local addonAccount   = CreateAddonAccount(name, nil, money)
			SharedAccounts[name] = addonAccount
		end
	end
	if cb then
		cb(true)
	end
end)

Add this code at the bottom of "esx_society/server/main.lua"

RegisterNetEvent('esx_society:refreshSociety', function(cb, triggerCheck)
	if triggerCheck then
		triggerCheck()
		return
	end
	Jobs = {}
	local result = MySQL.Sync.fetchAll('SELECT * FROM jobs', {})
	for i=1, #result, 1 do
		Jobs[result[i].name] = result[i]
		Jobs[result[i].name].grades = {}
	end
	local result2 = MySQL.Sync.fetchAll('SELECT * FROM job_grades', {})
	for i=1, #result2, 1 do
		Jobs[result2[i].job_name].grades[tostring(result2[i].grade)] = result2[i]
	end
	if cb then
		cb()
	end
end)

Notes:

  • Don't upload the script with FileZilla, Use Winscp if you are using FTP for file uploading.

  • Renaming of the script is not allowed.

  • We do not support custom frameworks, highly modified versions of ESX, or deprecated/outdated versions of anything.

Last updated