# Installation

### Add dependencies:

1. PolyZone: <https://github.com/mkafrin/PolyZone>
2. ox\_lib: <https://github.com/overextended/ox_lib>

### **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"

```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"

```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"

```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:**&#x20;

* 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.&#x20;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.menanak47.com/esx/ak47_cardealer/installation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
