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:
Mycroft
2022-11-26 17:15:05 +00:00
parent 8cb620dfe1
commit 18d054e076
+9 -1
View File
@@ -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)