Skip to content

feat(functions.lua): add ESX.GetJob() function to retrieve job data b… #1679

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions [core]/es_extended/server/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,18 @@ function ESX.GetJobs()
return ESX.Jobs
end

---@param jobName string
---@return table|nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use

---@return table?

function ESX.GetJob(jobName)
local job = ESX.Jobs[jobName]
if job then
return job
else
print(("[^3WARNING^7] Attempting to get invalid job: ^5%s^7"):format(jobName))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simply attempt to retun ESX.Jobs[jobName]. This function should be one line. It is expected that this function will be called via user input a lot, so having a warning printed can be quite annoying.

return nil
end
end

---@return table
function ESX.GetItems()
return ESX.Items
Expand Down
Loading