Player Jobs
Server exports to read and set a player's job, grade, duty state and action access.
Server exports have no source
Every player-scoped export takes the player's server id as its first argument.
getPlayerJob
A player's job the same table shape as the client's
getJobData.
local job, err = exports['hex_jobscreator']:getPlayerJob(5)Prop
Type
Returns
| Value | Meaning |
|---|---|
| table | the job |
nil, reason | invalid_player · player_not_found · no_job |
setPlayerJob
Sets a player's job and saves it to the database.
local ok, err = exports['hex_jobscreator']:setPlayerJob(5, 'police', 3, true)Prop
Type
Returns
| Value | Meaning |
|---|---|
true | job set and saved |
false, reason | see the reasons below |
Reasons
| Code | Meaning |
|---|---|
invalid_player | player id must be a number |
player_not_found | no such player on the server |
invalid_job | job name must be a non-empty string |
reserved_job | public cannot be assigned to a player |
unknown_job | no job with that name |
unknown_grade | that job has no such grade |
not_a_second_job | that job is not marked as usable in the second slot |
setPlayerDuty
Clocks a player in or out, keeping their job and grade, and saves it.
Note
Already being in the requested state counts as success.
local ok, err = exports['hex_jobscreator']:setPlayerDuty(5, false)Prop
Type
Returns
| Value | Meaning |
|---|---|
true | duty state applied |
false, reason | invalid_player · player_not_found · invalid_duty · no_job |
isPlayerOnDuty
Whether a player is clocked in.
local onDuty, err = exports['hex_jobscreator']:isPlayerOnDuty(5)Prop
Type
Returns
| Value | Meaning |
|---|---|
true | on duty |
true, 'no_duty_point' | the job has no duty point, so the player counts as always on duty |
false, reason | invalid_player · player_not_found · no_job · off_duty |
hasPlayerActionAccess
Whether a player's job grants an action menu action, checking both job slots.
Raw action names only
This takes raw action names only (handcuff_back, revive, give_license, …) no categories or
aliases. Those belong to the client's
hasPlayerAccess, which
also lists every action name.
local ok, err = exports['hex_jobscreator']:hasPlayerActionAccess(5, 'handcuff_back')Prop
Type
Returns
| Value | Meaning |
|---|---|
true | allowed |
false, reason | invalid_player · invalid_action · player_not_found · no_access |