Merge pull request #174 from FBFezz/main

Fixed esx_joblisting
This commit is contained in:
Mycroft
2022-03-26 15:10:09 +00:00
committed by GitHub
2 changed files with 19 additions and 19 deletions
+5 -11
View File
@@ -1,5 +1,4 @@
fx_version 'adamant'
fx_version 'bodacious'
game 'gta5'
description 'ESX Job Listing'
@@ -9,17 +8,12 @@ version '1.6.5'
shared_scripts {
'@es_extended/imports.lua',
'@es_extended/locale.lua',
'locales/*.lua',
'config.lua'
}
server_scripts {
'@oxmysql/lib/MySQL.lua',
'locales/*.lua',
'server/main.lua'
}
client_scripts {
'locales/*.lua',
'client/main.lua'
}
server_script 'server/main.lua'
client_script 'client/main.lua'
dependency 'es_extended'
+14 -8
View File
@@ -1,14 +1,18 @@
local availableJobs = {}
for k,v in pairs(ESX.Jobs) do
print(v.whitelisted)
if v.whitelisted == false then
availableJobs[k] = {label = v.label}
function getJobs()
local jobs = ESX.GetJobs()
local availableJobs = {}
for k,v in pairs(jobs) do
print(v.whitelisted)
if v.whitelisted == false then
availableJobs[k] = {label = v.label}
end
end
return availableJobs
end
ESX.RegisterServerCallback('esx_joblisting:getJobsList', function(source, cb)
cb(availableJobs)
local jobs = getJobs()
cb(jobs)
end)
function IsNearCentre(player)
@@ -27,10 +31,12 @@ end
RegisterServerEvent('esx_joblisting:setJob')
AddEventHandler('esx_joblisting:setJob', function(job)
local source = source
local xPlayer = ESX.GetPlayerFromId(source)
local jobs = getJobs()
if xPlayer and IsNearCentre(source) then
if availableJobs[job] then
if jobs[job] then
xPlayer.setJob(job, 0)
end
end