Docs/Yecoyz Multijob

Exports

Server and client exports and events of Yecoyz Multijob, and how to use them from a boss menu.

A target is an online player's server id or a character identifier (online or offline). Functions that change something return true, or false and a reason: no_player, no_job, no_grade, not_held, ignored, held, full, exclusive, cooldown, dead, in_vehicle, blocked or failed.

Server exports

Export Arguments Returns Description
GetJobs target List of { job, grade, active } Every job the player keeps, the one they work included
HasJob target, job, minGrade? true or false Whether they keep the job (working it now or not), at minGrade or higher
CanAddJob target, job true, or false and a reason Checks the limit, Config.Ignore and exclusive groups. Call it before hiring
AddJob target, job, grade true, or false and a reason Adds the job. They keep working their current job
RemoveJob target, job true, or false and a reason Takes the job away. If they work it now, they become unemployed
SetJobGrade target, job, grade true, or false and a reason Changes their rank in a job, also one they don't work now and for offline players
SwitchJob source, job true, or false and a reason Switches an online player to a job they keep, without the cooldown and switch checks
GetJobMembers job List of { identifier, grade, name, active, source } Everyone who keeps the job, online or not, also those working another job now
RemapGrades job, map Number changed After renumbering ranks: { [oldGrade] = newGrade }
GetMaxJobs source Number How many jobs they can keep. 0 = no limit
OpenMenu source Nothing Opens the jobs menu for the player
lua
-- server
local ok, reason = exports.yecoyz_multijob:CanAddJob(target, 'police')
if not ok then
    print(('can\'t hire: %s'):format(reason)) -- 'full', 'exclusive', 'held' or 'ignored'
    return
end
exports.yecoyz_multijob:AddJob(target, 'police', 0)

if exports.yecoyz_multijob:HasJob(target, 'police', 2) then
    -- keeps police at rank 2 or higher
end

Client exports

Export Description
OpenMenu() Opens the jobs menu
CloseMenu() Closes it
IsOpen() Whether it is open

Server events

lua
AddEventHandler('yecoyz_multijob:server:jobAdded', function(identifier, job, grade, source) end)
AddEventHandler('yecoyz_multijob:server:jobRemoved', function(identifier, job, source, why) end) -- why: fired, quit, admin, removed, replaced
AddEventHandler('yecoyz_multijob:server:jobSwitched', function(source, fromJob, toJob) end)

source is nil when the player is offline.

Using it from a boss menu

Your boss menu keeps working without changes: hires, fires and promotions are picked up. For the best result:

  • Call CanAddJob(target, job) before hiring, so a player with a full list gets a clear message.
  • List staff with GetJobMembers(job) too, so people who keep the job but work another one right now still show up.
  • For a member who works another job right now, fire with RemoveJob and promote with SetJobGrade. Setting their framework job would switch them away from the job they work.
  • After renumbering or swapping ranks, call RemapGrades(job, map).
Tip

Yecoyz Boss Menu 1.0.8 and newer does all of this when Yecoyz Multijob runs.

Stuck on this step?

Open a ticket in the Discord with what you tried and what you see, and I'll help you get it running.

Ask on Discord
Up nextOverviewWhat Yecoyz MDT does and what's included.