Hi everyone!
I’m trying to check the player’s XP before setjob.
I have:
RegisterServerEvent('esx_empregos:setJobPolice')
AddEventHandler('esx_empregos:setJobPolice', function(job)
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
local xp = Getxp(xp)
if xPlayer.Getxp >= 100000 then
xPlayer.setJob("police", 0) -- 0 is job grade
TriggerClientEvent('esx:showNotification', source, 'You were hired ~g~' .. xPlayer.getName())
else
TriggerClientEvent('esx:showNotification', source, 'You not enough Rank ~g~' .. xPlayer.getName())
end
end)
and function:
function Getxp(xp)
local xp = MySQL.Sync.fetchScalar('SELECT xp FROM user WHERE xp = @xp' , {
['@xp'] = xp
})
if xp then
return xp
else
return 0
end
end
But it not work
Pls help!