From 18d054e0765ee251165c1029b289152b4bb98b79 Mon Sep 17 00:00:00 2001 From: Mycroft Date: Sat, 26 Nov 2022 17:15:05 +0000 Subject: [PATCH] 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 --- [esx_addons]/esx_joblisting/server/main.lua | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/[esx_addons]/esx_joblisting/server/main.lua b/[esx_addons]/esx_joblisting/server/main.lua index 7be7b151..648c4c2b 100644 --- a/[esx_addons]/esx_joblisting/server/main.lua +++ b/[esx_addons]/esx_joblisting/server/main.lua @@ -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)