[FREE] [QBCore] Job queue

Job queue system for QBCore

Simple custom made queue system for an upcoming project of mine but could also be used in any other job scripts too.

This script is an early version so if you have any suggestions, fixes or issues - please post them in the Issues section or contribute using pull requests.

Thank you in advance! :slight_smile:

Github - Download, Issues etc.


Adding job

Single job (Server-side) Recommended


TriggerEvent('hiype-jobqueue:server:add-job', pJobName, pMaxQueueSize, pWaitTime)

Single job (Client-side)


TriggerServerEvent('hiype-jobqueue:server:add-job', pJobName, pMaxQueueSize, pWaitTime)

Multiple jobs


for k,v in pairs(pJobArray) do

TriggerEvent('hiype-jobqueue:server:add-job', k, pMaxQueueSize, pWaitTime)

end

Parameters

pJobArray (Array) - Used QBCore job formatting for testing which can be found at qb-core->shared->jobs

pJobName (String) - Name of the job that you wish to add

pMaxQueueSize (Unsigned integer > 0) - Amount of players allowed to be in queue

pWaitTime (unsigned integer) - Time before next player gets assigned a job in the queue


Adding sub job

Single sub job (Server-side) Recommended


TriggerEvent('hiype-jobqueue:server:add-subjob', pJobName, pSubJobName, pWaitTime)

Single sub job (Client-side)


TriggerServerEvent('hiype-jobqueue:server:add-subjob', pJobName, pSubJobName, pWaitTime)

Multiple sub jobs


for k, v in pairs(pSubJobArray) do

TriggerEvent('hiype-jobqueue:server:add-subjob', k, v.name, pWaitTime)

end

Parameters

pJobName (String) - Name of the job that you wish to add the sub job to

pWaitTime (unsigned integer) - Time before next player gets assigned a job in the queue


Adding jobs with sub jobs

Example


for k,_ in pairs(pJobArray) do

TriggerEvent('hiype-jobqueue:server:add-job', k, pMaxQueueSize, pWaitTime)

for _, subV in pairs(pSubJobArray) do

TriggerEvent('hiype-jobqueue:server:add-subjob', k, subV.name, pMaxQueueSize2)

end

end


Join queue


QBCore.Functions.TriggerCallback('hiype-jobqueue:server:join-queue', function(result)

print("Received janitor job to: " .. tostring(result))

end, pJobName)

Parameters

pJobName (String) - Name of the job that you wish to join queue to


Leave queue


TriggerServerEvent('hiype-jobqueue:server:leave-queue')


Configurations

Config.QueueCheckRate (unsigned int = msec) - How often to check in msec if a player that is in queue has gone offline to remove the player

Config.JobAssignerRate (unsigned int = msec) - Amount timer time is reduced by in msec (also used in Wait time)

Config.DebugLogs (boolean) - Enables some logging for the queue system

Config.EnableQueuePrintCommand (boolean) - Enables registration of a command for players to print queue in server logs

Config.CommandPermissionLevel (String) - Level of permission required to use the command if enabled


Commands

/queue - Prints queue contents in server logs if enabled in config file

My other scripts

[PAID] [QBCore] Janitor job/Custom interaction job script
[PAID] [QBCore] Debug menu
[FREE] [QBCore] Car Delivery Rewrite
[FREE] [QBCore] Scenery
[FREE] [QBCore] [Standalone] Photoshoot

4 Likes

Been looking for something like this for a while now. Cheers for free release, can’t wait to test it out!

Im happy to hear that! Forgot to add a note tho, i havent tested it with multiple players yet.