esx_joblisting
Set up esx_joblisting, the ESX Legacy job center. Hide whitelisted jobs, customize job cards, and use the UpdateJobProgress and ShowTasks exports.
esx_joblisting is the job center: a map marker that opens a NUI where players browse non-whitelisted jobs, read a description, set a waypoint, apply, or quit to unemployed. It also exposes a small task and progress API that other job scripts can use to show goals in the UI.
Overview
| Resource | esx_joblisting (version 1.0) |
| Side | client + server, NUI (web/index.html) |
| Dependencies | esx_lib, es_extended |
| Also used | oxmysql |
| Database | jobs.whitelisted column |
Which jobs appear is controlled by the database, not by the config: every job with whitelisted = false that has a grade 0 is listed. Config.JobDetails only adds text, images and tasks to those cards.
Installation
Make sure the whitelisted column exists
esx_joblisting.sql runs:
ALTER TABLE jobs add whitelisted BOOLEAN NOT NULL DEFAULT FALSE;Current ESX Legacy databases (including the txAdmin recipe) already have this column. Running the file again fails with "Duplicate column name", which you can ignore. Only run it on very old databases.
Start it
ensure es_extended
ensure esx_lib
ensure esx_joblistingHide jobs that need an application
UPDATE jobs SET whitelisted = 1 WHERE name IN ('police', 'ambulance', 'mechanic');Restart the server so ESX reloads the jobs.
Configuration
| Key | Default | Description |
|---|---|---|
Config.DrawDistance | 15.0 | Marker draw distance. Also the server-side radius for opening the menu and changing jobs. |
Config.ZoneSize | { x = 2.7, y = 2.7, z = 0.5 } | Marker size. The interaction radius is half of x. |
Config.MarkerColor | { r = 100, g = 200, b = 104 } | Marker color. |
Config.MarkerType | 27 | Marker type. |
Config.Debug | ESX.GetConfig().EnableDebug | Read from es_extended. Not used by the current code. |
Config.Locale | GetConvar('esx:locale', 'en') | Language. |
Config.JobDetails | miner, delivery, garbage | Extra card data per job name, see below. |
Config.UnemployedJob | 'unemployed' | Job set when a player clicks Quit. |
Config.Zones | { vector3(-265.08, -964.1, 30.3) } | Job center locations. |
Config.Blip | { Enabled = true, Sprite = 407, Display = 4, Scale = 0.8, Colour = 27, ShortRange = true } | Map blip for each zone. |
Config.JobDetails
Keyed by job name. Every field is optional.
| Field | Type | Description |
|---|---|---|
subtitle | string | Short line under the job name. |
description | string | Long text. \n\n creates paragraphs. |
image | string | Path inside web/, for example 'assets/miner.png'. |
rating | number | Difficulty, 0 to 5 stars. |
requirement | string | Shown as a badge. Defaults to "No requirements". |
location | { x, y } | Enables the mark location button, which sets a GPS waypoint. |
tasks | table | Default task list: { title, description, current, target }. Replaced by stored progress when the player has some. |
Config.JobDetails.taxi = {
subtitle = 'Drive the city',
rating = 2,
requirement = 'Driver license',
location = { x = 903.3, y = -170.5 },
description = 'Pick up passengers at the depot and drive them anywhere in Los Santos.',
}The default config describes delivery and garbage, which are not part of the official addons. Their cards only appear if your database has jobs with those names.
Exports
UpdateJobProgress (server)
Stores stats and tasks for a job in the player's metadata (joblisting key) and pushes the updated profile to the client.
exports.esx_joblisting:UpdateJobProgress(playerId, jobName, data)| Name | Type | Description |
|---|---|---|
playerId | number | Server ID. |
jobName | string | Job the progress belongs to. |
data.stats | table? | Up to 64 key/value pairs (numbers or strings up to 64 characters). stats.extra may hold up to 3 { label, value } entries. |
data.tasks | table? | Up to 64 { title, description?, current, target } entries. current and target are integers from 0 to 100000. |
Returns true on success, false when the player is not loaded or the arguments have the wrong type. Invalid entries are dropped silently.
local function rewardRock(playerId, mined)
exports.esx_joblisting:UpdateJobProgress(playerId, 'miner', {
stats = { rocks = mined },
tasks = {
{ title = 'Extract mineral rock', description = 'Break rocks from active quarry veins.', current = mined, target = 40 },
},
})
endShowTasks (client)
exports.esx_joblisting:ShowTasks(tasks, grade)| Name | Type | Description |
|---|---|---|
tasks | table | List of { title, description?, current, target }. |
grade | string? | Subtitle shown in the HUD, usually the grade label. |
HideTasks (client)
exports.esx_joblisting:HideTasks()ShowTaskProgress (client)
Shows a toast with a progress bar for 5 seconds.
exports.esx_joblisting:ShowTaskProgress({ title = 'Deliver processed sacks', current = 3, target = 10 })Server callbacks
| Callback | Arguments | Returns |
|---|---|---|
esx_joblisting:open | none | { ok, jobs, profile }. ok is false outside a job center. Rate limited. |
esx_joblisting:apply | jobName | { ok, message?, profile? }. |
esx_joblisting:quit | none | Sets Config.UnemployedJob. |
esx_joblisting:getJobsList | none | List of available jobs. Rate limited. |
Events
| Event | Side | Description |
|---|---|---|
esx_joblisting:setJob | server (net) | (jobName) legacy entry point. Runs the same checks as apply. |
esx_joblisting:profileUpdated | client | (profile) sent by UpdateJobProgress, refreshes the open UI. |
Security
esx_joblisting:apply and esx_joblisting:setJob change a player's job, so they are classic targets. The server checks distance to a job center, rejects whitelisted or missing jobs, only sets grade 0, and applies a 1.5 second cooldown. Keep jobs that need vetting marked whitelisted = 1, or a cheater can still join them by standing at the job center.
Common issues
- Police or EMS show up in the list. Their
whitelistedvalue is0. See the installation steps. - A job is missing. It needs
whitelisted = 0and a grade0row injob_grades. - Menu opens and closes immediately with an error. The server did not confirm you are near a zone. Make sure
Config.Zonesmatches the marker you are standing on, and do not moveConfig.DrawDistancebelow the marker size. - Card has no picture. Add
imageinConfig.JobDetailsand put the file inweb/assets/. It is covered by theweb/assets/*files entry.
Related
Frequently asked questions
Independent documentation
Last updated on
esx_hud
esx_hud is the default ESX Legacy HUD with status bars, money, job, speedometer, indicators and saved mileage. Config keys, exports and events.
esx_jobs
Configure esx_jobs for ESX Legacy, the miner, lumberjack, fisherman, fueler, slaughterer and tailor jobs. Zone format, vehicle deposits, events and fixes.