Problem with my Police Garage

When i try to spawn my vehicle a error is put in the console for the line 3

RegisterServerEvent('cp:spawn')
AddEventHandler('cp:spawn', function()

TriggerEvent('es:getPlayerFromId', tonumber(args[2]), source, function(target, user)
  
if(player_jobs[user.identifier] or (tonumber(user.permission_level) > 2))then
local job = player_jobs[user.identifier]

if(job)then
  job = player_jobs[user.identifier].job
end

if(GetPlayerName(tonumber(args[2])))then
  TriggerClientEvent('police', source)
  TriggerClientEvent('marche', source)
else
  TriggerClientEvent('marchepas', source)
  
   end
  end
 end)
end)

sry for my vry bad english :confused:

PS: i use the system job of advanced rp

replace line 3 :

This :

TriggerEvent('es:getPlayerFromId', tonumber(args[2]), source, function(target, user)

By this, i think :

TriggerEvent('es:getPlayerFromId', source, function(target, user)

tried this :

RegisterServerEvent('cp:spawn')
AddEventHandler('cp:spawn', function()
	TriggerEvent('es:getPlayerFromId', source, function(target, user)
		local player = user.identifier
		local permission = user.permission_level
	
		if(player_jobs[player] or (tonumber(permission) > 2))then
		
			local job = player_jobs[player]
			
			if(job)then
				job = player_jobs[player].job
			end	
			
			TriggerClientEvent('police', source)
			TriggerClientEvent('marche', source)
		end
	end)
end)

i try this thx dude ^^

I have try the code and it doesnt work :confused:
but i have modified the code

RegisterServerEvent('cp:spawn')

AddEventHandler('cp:spawn', function(source, user)

TriggerEvent("es_roleplay:getPlayerJob", function(job)

local permission = user.permission_level

if (job.job == "police" or tonumber(user.permission_level) > 2) then

TriggerClientEvent('police', source)

TriggerClientEvent('marche', source)

else

TriggerClientEvent('marchepas', source)

end

end)

end)

and it doesnt work too xD but my code is better 8)

I haveput my code on pastebin… the forum is bugged… :frowning:

Hello tried this :

RegisterServerEvent(‘cp:spawn’)
AddEventHandler(‘cp:spawn’, function(source)
TriggerEvent(“es_roleplay:getPlayerJob”, function(job)
if(job)then
print(“----- job>”…job)

        if(job.job == "police")then
  		print("----- job.job>"..job.job)
  		TriggerClientEvent('police', source)
  		TriggerClientEvent('marche', source)
  		print("----- marche")
  	else           
  		TriggerClientEvent('marche pas', source)
  		print("----- marche pas")
  	end
    end
end)

end)

and look in the server console

Also look in the game with the F8 key, if there is no error