Giter VIP home page Giter VIP logo

hiype-jobqueue's Introduction

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! :)


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, pSubJobNum, pPreviousSubJob)

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

hiype-jobqueue's People

Contributors

hiype avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

raxic7 mrberkk

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.