Esx_society line 26 error

I have an error in my esx_society at line 26, the code wil be down below. The is:

[ script:esx_society] SCRIPT ERROR: @esx_society/server/main.lua:26: attempt to index a nil value (field ‘?’)
[ script:esx_society] > cb (@esx_society/server/main.lua:26)
[ script:esx_society] > fn (@mysql-async/lib/MySQL.lua:19)
[ script:esx_society] > (@oxmysql/dist/build.js:22234)
[ script:esx_society] > processTicksAndRejections (node:internal/process/task_queues:96)
[ script:esx_society] > async rawQuery (@oxmysql/dist/build.js:22224)

Anyone have any ideas?

The lines off code at the line.

ESX = nil
local Jobs = {}
local RegisteredSocieties = {}

TriggerEvent(‘esx:getSharedObject’, function(obj) ESX = obj end)

function GetSociety(name)
for i=1, #RegisteredSocieties, 1 do
if RegisteredSocieties[i].name == name then
return RegisteredSocieties[i]
end
end
end

MySQL.ready(function()
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

end)

AddEventHandler(‘esx_society:registerSociety’, function(name, label, account, datastore, inventory, data)
local found = false

local society = {
	name = name,
	label = label,
	account = account,
	datastore = datastore,
	inventory = inventory,
	data = data
}

for i=1, #RegisteredSocieties, 1 do
	if RegisteredSocieties[i].name == name then
		found, RegisteredSocieties[i] = true, society
		break
	end
end

if not found then
	table.insert(RegisteredSocieties, society)
end

end)

AddEventHandler(‘esx_society:getSocieties’, function(cb)
cb(RegisteredSocieties)
end)

AddEventHandler(‘esx_society:getSociety’, function(name, cb)
cb(GetSociety(name))
end)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.