I’am having trouble with making some blips invisible to the police job.
The error is:
Error resuming coroutine: client/main.lua:22: attempt to index a nil value (field 'job')
stack traceback:
client/main.lua:22: in function <client/main.lua:21>
The offending code is:
ESX = nil
local PlayerData = {}
Citizen.CreateThread(function()
while ESX == nil do
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
Citizen.Wait(0)
end
end)
RegisterNetEvent('esx:playerLoaded')
AddEventHandler('esx:playerLoaded', function(xPlayer)
PlayerData = xPlayer
end)
RegisterNetEvent('esx:setJob')
AddEventHandler('esx:setJob', function(job)
PlayerData.job = job
end)
Citizen.CreateThread(function()
if PlayerData.job.name == 'police' then -- errors here trying to filter out cops :c
Citizen.Wait(0)
else
for i=1, #Config.Map, 1 do
esxmap_blip = AddBlipForCoord(Config.Map[i].x, Config.Map[i].y, Config.Map[i].z)
SetBlipSprite (esxmap_blip, Config.Map[i].id)
SetBlipScale (esxmap_blip, 0.9)
SetBlipDisplay(esxmap_blip, 4)
SetBlipColour (esxmap_blip, Config.Map[i].color)
SetBlipAsShortRange(esxmap_blip, true)
BeginTextCommandSetBlipName("STRING")
AddTextComponentString(Config.Map[i].name)
EndTextCommandSetBlipName(esxmap_blip)
end
end
end)
I tried to use this topic that Cheleber helped another user in with a similar piece of code:
Help Article referenced
Thanks for your help.