Nick78111 / ConnectQueue

Connection queue for FiveM
MIT License
77 stars 120 forks source link

ConnectQueue


Easy to use queue system for FiveM with:

Please report any bugs on the release thread Here or through GitHub.

How to install


ConVars


set sv_debugqueue true # prints debug messages to console
set sv_displayqueue true # shows queue count in the server name '[count] server name'

How to use / Examples


To use the API add server_script "@connectqueue/connectqueue.lua" at the top of the __resource.lua file in question. I would also suggest adding dependency "connectqueue" to it aswell. You may now use any of the functions below, anywhere in that resource.

OnReady

This is called when the queue functions are ready to be used.

    Queue.OnReady(function() 
        print("HI")
    end)

All of the functions below must be called AFTER the queue is ready.

OnJoin

This is called when a player tries to join the server. Calling allow with no arguments will let them through. Calling allow with a string will prevent them from joining with the given message. allow must be called or the player will hang on connecting...

Queue.OnJoin(function(source, allow)
    allow("No, you can't join")
end)

AddPriority

Call this to add an identifier to the priority list. The integer is how much power they have over other users with priority. This function can take a table of ids or individually.

-- individual
Queue.AddPriority("STEAM_0:1:33459672", 100)
Queue.AddPriority("steam:110000103fd1bb1", 10)
Queue.AddPriority("ip:127.0.0.1", 25)

-- table
local prioritize = {
    ["STEAM_0:1:33459672"] = 100,
    ["steam:110000103fd1bb1"] = 10,
    ["ip:127.0.0.1"] = 25,
}
Queue.AddPriority(prioritize)

RemovePriority

Removes priority from a user.

Queue.RemovePriority("STEAM_0:1:33459672")

IsReady

Will return whether or not the queue's exports are ready to be called.

print(Queue.IsReady())

Other Queue Functions

You can call every queue function within sh_queue.lua.

local ids = Queue.Exports:GetIds(src)

-- sets the player to position 1 in queue
Queue.Exports:SetPos(ids, 1)
-- returns whether or not the player has any priority
Queue.Exports:IsPriority(ids)
--- returns size of queue
Queue.Exports:GetSize()
-- plus many more...