Attempt to index a nil value (global 'esx') on script

i have a problem with one script that is not working…
[script:ssdcrp_] SCRIPT ERROR: @ssdcrp_/server.lua:21: attempt to index a nil value (global ‘ESX’)
[script:ssdcrp_] > ref (@ssdcrp_/server.lua:21)

Here is the Server Lua

ESX = nil

local frecuencia = {}

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

RegisterServerEvent(‘virtual_alerts:active’)
AddEventHandler(‘virtual_alerts:active’, function(type)
print(type)
local source = source
TriggerClientEvent(‘virtual_alerts:active’,-1,type)
end)

RegisterServerEvent(‘virtual_alerts:disable’)
AddEventHandler(‘virtual_alerts:disable’, function()
local source = source
TriggerClientEvent(‘virtual_alerts:disable’,-1)
end)

RegisterCommand(“defcon”, function(source, args, rawCommand)
local xPlayer = ESX.GetPlayerFromId(source)
local job = xPlayer.job.name
local type = tonumber(args[1])
if job == “police” then
if type then
if type <= 5 and type >= 1 then
TriggerClientEvent(‘virtual_alerts:active’,-1,type)
else
if type == 0 then
TriggerClientEvent(‘virtual_alerts:disable’,-1,type)
else
TriggerClientEvent(‘chatMessage’ , source , “^1[SS:RP]^0 ^7Debes utilizar un nivel correcto. (0/1/2/3/4/5)”)
end
end
else
TriggerClientEvent(‘chatMessage’ , source , “^1[SS:RP]^0 ^7Debes utilizar un nivel correcto. (0/1/2/3/4/5)”)
end
else
TriggerClientEvent(‘chatMessage’ , source , “^1[SS:RP]^0 ^7No tienes permiso para utilizar este comando.”)
end

end, false)

Hi,

Make sure the resources are starting in the right order in your cfg.
Also make sure es_extended is started without errors

Regards

1 Like

yes the es extended is working fine, the order is also correct but still saying this error

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