Docs/Yecoyz Multijob

Configuration

Every option in config.lua, and the hooks in the open folder.

Everything is in config.lua, with a comment on each line. Restart the resource after a change.

Jobs a player can keep

lua
Config.MaxJobs = 3              -- how many jobs a player can keep, the job they work included. 0 = no limit
Config.Unlimited = 'group.admin' -- players with this permission have no limit. false = nobody
Config.Ignore = {}              -- jobs never kept in the list, e.g. { 'gang' }
Config.Exclusive = {
    -- { 'police', 'sheriff' }, -- only one job from each group can be kept
}

A permission is an ace, or the ESX group or QBCore permission.

Changes from other scripts

lua
Config.KeepOldJob = true   -- another script gives a new job: true = the old job stays in the list
Config.RemoveOnFire = true -- a script sets the default job ('unemployed'): the job leaves the list

Both also apply to players who were offline when it happened. They are checked when the player logs in.

Switching

lua
Config.Switch = {
    Cooldown = 30,          -- seconds between two switches (0 = none)
    Duty = 'off',           -- after a switch: 'off', 'on' or 'keep' (same as before the switch)
    BlockWhenDead = true,   -- can't switch while dead or downed
    BlockInVehicle = false, -- can't switch while in a vehicle
}

Config.Quit = { Enabled = true, NotifyBosses = true } -- quit a job from the menu, online bosses get a message
Config.OffWork = true                                 -- the "Go off work" button

Find work

Jobs anyone can take from the menu, without a boss or an admin:

lua
Config.JobCenter = {
    Enabled = true,
    SwitchOnTake = true, -- start working the job right away
    Jobs = {
        { job = 'taxi', grade = 0, icon = 'car', text = 'Drive people around the city.' },
        { job = 'garbage', grade = 0, icon = 'truck', text = 'Empty the bins on your route.' },
    },
}

grade is the rank they start at. The label, rank name and salary come from your framework's job.

Opening the menu

lua
Config.Command = {
    Enabled = true, -- false: only the tablet app and the OpenMenu export
    Name = 'jobs',
    Key = 'J',      -- default key, players can change it. '' = no key
}

Config.Tablet = {
    Enabled = true,
    Resource = 'yecoyz_tablet',
    AppId = 'yecoyz_multijob',
    Label = 'Jobs',
    Icon = 'briefcase',
    Color = '#29292f',
    InstalledByDefault = true, -- false: players install it from the tablet's Apps app first
    Removable = true,
}

The tablet app is only added while yecoyz_tablet runs.

Other Yecoyz scripts

lua
Config.Duty = {
    Resource = 'yecoyz_duty',
    ShowHours = true,          -- hours worked this week on each job
    TabletApp = 'yecoyz_duty', -- the Shifts button opens this app on the tablet
    Command = 'duty',          -- and this command outside the tablet
}

Config.BossMenu = {
    Resource = 'yecoyz_bossmenu',
    Button = true,          -- a Company button for bosses
    TabletApp = 'bossmenu', -- the Company app on the tablet
}

Admin and logs

lua
Config.Admin = {
    Permission = 'group.admin',
    Page = true,     -- an Admin page in the menu: see and change any online player's jobs
    Commands = true, -- /addjob [id] [job] [grade], /removejob [id] [job], /checkjobs [id]
}

Config.Logs = true -- switches, quits and admin changes, through yecoyz_core's logs (Discord webhook)
Note

On Qbox only /checkjobs is added, because qbx_core has its own /addjob and /removejob.

Config.Icons sets the icon of each job in the menu (lucide icon names). Jobs that aren't listed get a briefcase. Config.Locale picks the language file in locales/ (English and Swedish are included).

Hooks

The open/ folder has hooks for your server. They are plain Lua, so you can change them.

Hook File Use
OpenServer.CanSwitch(source, fromJob, toJob) open/server.lua Return false and a message to stop a switch, for example while cuffed or in jail
OpenServer.OnSwitched(source, fromJob, toJob) open/server.lua Runs after a switch went through
OpenServer.CanTakeJob(source, job) open/server.lua Return false and a message to stop taking a job from Find work, for example without a driver's licence
OpenClient.CanOpen() open/client.lua Return false to keep the menu closed
OpenClient.OnOpen() / OnClose() open/client.lua Hide and show your HUD
lua
-- open/server.lua: no switching while cuffed (the state your handcuff script sets, here ox_lib / qbx handcuffs)
function OpenServer.CanSwitch(source, fromJob, toJob)
    if Player(source).state.isCuffed then
        return false, 'You can\'t do that while cuffed.'
    end
    return true
end
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 nextExportsServer and client exports and events of Yecoyz Multijob, and how to use them from a boss menu.