Once more I seem to be stuck on something simple. I also can’t seem to find much information about it. There is only one similar topic on the forum here which is client side. And I can’t even get that to work for me.
All I need is to check the players job and put that information in a local variable.
I’ve tried:
ESX = nil
Citizen.CreateThread(function()
while ESX == nil do
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
Citizen.Wait(0)
end
while ESX.GetPlayerData() == nil do
Citizen.Wait(10)
end
end)
local source = source
local job = ESX.GetPlayerData(source).job
Also tried:
local source = source
local xPlayer = ESX.GetPlayerFromId(source)
local job = xPlayer.job.name
For some reason I can’t use the source to find the player information.
If I use a target’s information it works just fine.
local _source = source
local player = player
local xPlayer = ESX.GetPlayerFromId(player)
local job = xPlayer.job.name
print(job)
if source == nil then
print("no")
else
print("yes")
end
local _player = ESX.GetPlayerFromId(_source)
if _player == nil then
print("f me")
else
print("nais")
end