mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 04:01:22 +00:00
feat(esx_joblisting): Actual Security
This should in theory, stop the event from being abused, since mod menus were previously able to Trigger This event to set the user to a whitelisted job, assuming the user was near the job centre, so this now checks to make sure that the job is a non-whitelisted job, and warns when abused
This commit is contained in:
@@ -14,6 +14,12 @@ ESX.RegisterServerCallback('esx_joblisting:getJobsList', function(source, cb)
|
||||
cb(jobs)
|
||||
end)
|
||||
|
||||
function IsJobAvailable(job)
|
||||
local jobs = ESX.GetJobs()
|
||||
local JobToCheck = jobs[job]
|
||||
return not JobToCheck.whitelisted
|
||||
end
|
||||
|
||||
function IsNearCentre(player)
|
||||
local Ped = GetPlayerPed(player)
|
||||
local PedCoords = GetEntityCoords(Ped)
|
||||
@@ -37,11 +43,13 @@ AddEventHandler('esx_joblisting:setJob', function(job)
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
local jobs = getJobs()
|
||||
|
||||
if xPlayer and IsNearCentre(source) then
|
||||
if xPlayer and IsNearCentre(source) and IsJobAvailable(job) then
|
||||
if ESX.DoesJobExist(job, 0) then
|
||||
xPlayer.setJob(job, 0)
|
||||
else
|
||||
print("[^1ERROR^7] Tried Setting User ^5".. source .. "^7 To Invalid Job - ^5"..job .."^7!")
|
||||
end
|
||||
else
|
||||
print("[^3WARNING^7] User ^5".. source .. "^7 Attempted to Exploit ^5`esx_joblisting:setJob`^7!")
|
||||
end
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user