ConnectQueue is a queue system that makes use of the deferral features in FiveM. I’m too lazy to write anything here, so take a look at the readme on github. I might whip up a good example demonstrating what you can do with this resource in a couple days.
Added a little update that adds a sort of safety net. I have seen on other queue scripts that players can sometimes join at random and completely bypass the queue, I don't know if it's because their script is bad, or if it's something wrong on FiveM's part. This will kick players who join that didn't properly wait in queue and aren't greenlit.
Note: If you restart the resource, it will kick all online players for not being greenlit, I will fix this soon.
FXServer (starting from the alpha update later today: if you’re on the FiveM Discord e-mail pr@fivem.net your nickname and you’ll be added to the group that gets prereleases) will include some enhancements that’ll allow this to work a bit better:
AddEventHandler('playerConnecting', function(name, setCallback, deferrals)
-- mark this connection as deferred
deferrals.defer()
-- save source
local s = source
for i = 1, 20 do
-- of course deferrals can be saved in a local too, just make sure it gets cleared when done!
-- update just sends a status message to the client, that'll show instead of 'Connecting'
deferrals.update('hey, wait ' .. tostring(20 - i) .. ' seconds')
Wait(1000)
end
-- accept the client, or reject the connection by passing a reason to `done`
deferrals.done()
end)
Citizen.CreateThread(function()
local initHostName = GetConvar('sv_hostname')
while true do
Wait(1000)
-- can for example be used to show a semi-live pending queue count
-- keep in mind that this will only update on a heartbeat
SetConvar('sv_hostname', '[' .. tostring(#GetPlayers()) .. '] ' .. initHostName)
end
end)
Was able to iron out some bugs with the help of Ykkris. There seems to be an issue with the green lighting system so in this update, it will currently be disabled by default, if you do enable it, I am 99% sure you will run into errors with players being kicked when they join.
Nice script !
I have a probleme, i set the “PlaceInQueueAt” at false, but the people are joining the Queue since we are 20 on the server… So we are kind of stuck at 20…
I meant this script itself will be obsolete because I have made another from scratch with deferrals, and I don’t plan on doing anything with this one anymore, so this one will be pointless when FXS is released. New one isn’t completely finished yet though.
You can any tips on fixing this queue system? Seems after so long the queue system bugs out, if i have it set to 32,. after a while it starts degrading and putting people in a queue at say 15 and stuff?