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! :)
TriggerEvent('hiype-jobqueue:server:add-job', pJobName, pMaxQueueSize, pWaitTime)
TriggerServerEvent('hiype-jobqueue:server:add-job', pJobName, pMaxQueueSize, pWaitTime)
for k,v in pairs(pJobArray) do
TriggerEvent('hiype-jobqueue:server:add-job', k, pMaxQueueSize, pWaitTime)
end
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
TriggerEvent('hiype-jobqueue:server:add-subjob', pJobName, pSubJobName, pWaitTime)
TriggerServerEvent('hiype-jobqueue:server:add-subjob', pJobName, pSubJobName, pWaitTime)
for k, v in pairs(pSubJobArray) do
TriggerEvent('hiype-jobqueue:server:add-subjob', k, v.name, pWaitTime)
end
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
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
QBCore.Functions.TriggerCallback('hiype-jobqueue:server:join-queue', function(result)
print("Received janitor job to: " .. tostring(result))
end, pJobName, pSubJobNum, pPreviousSubJob)
pJobName (String) - Name of the job that you wish to join queue to
TriggerServerEvent('hiype-jobqueue:server:leave-queue')
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
/queue - Prints queue contents in server logs if enabled in config file