Hello everyone, I am trying to modify the policejob script to allow the captain of the police to give the recruit job to someone after an interview. This is what I have so far:
if action == ‘identity_card’ then
OpenIdentityCardMenu(closestPlayer)
elseif action == ‘search’ then
OpenBodySearchMenu(closestPlayer)
elseif action == ‘handcuff’ then
TriggerServerEvent(‘esx_policejob:handcuff’, GetPlayerServerId(closestPlayer))
elseif action == ‘drag’ then
TriggerServerEvent(‘esx_policejob:drag’, GetPlayerServerId(closestPlayer))
elseif action == ‘put_in_vehicle’ then
TriggerServerEvent(‘esx_policejob:putInVehicle’, GetPlayerServerId(closestPlayer))
elseif action == ‘out_the_vehicle’ then
TriggerServerEvent(‘esx_policejob:OutVehicle’, GetPlayerServerId(closestPlayer))
elseif action == ‘seatbeltchecker’ then
TriggerServerEvent(‘seatbeltchecker’)
elseif action == ‘sendtojail’ then
JailPlayer(GetPlayerServerId(closestPlayer))
elseif action == ‘communityservice’ then
SendToCommunityService(GetPlayerServerId(closestPlayer))
elseif action == ‘fine’ then
OpenFineMenu(closestPlayer)
elseif action == ‘license’ then
ShowPlayerLicense(closestPlayer)
elseif action == ‘givejob’ then
TriggerServerEvent(‘esx_policejob:setJob’,GetPlayerServerId(closestPlayer), ‘police’)
elseif action == ‘unpaid_bills’ then
OpenUnpaidBillsMenu(closestPlayer)
end
And on the server script I added this:
RegisterNetEvent(‘esx_police:setJob’)
AddEventHandler(‘esx_police:setJob’, function(job)
ESX.PlayerData.job = job
end)
But when I click the button I get the following error:
[script:esx_policejob] SCRIPT ERROR: @esx_policejob/server/main.lua:532: attempt to index a nil value (field ‘PlayerData’)
[script:esx_policejob] > setJob (@es_extended/server/classes/player.lua:321)
[script:esx_policejob] > cb (@es_extended/server/commands.lua:11)
[script:esx_policejob] > ref (@es_extended/server/functions.lua:130)
Anyone know how to do this correctly? Thanks in advance!