Hi,
I can't get reserved slots in ULX to work, so I started debugging some in the GLua code (addons/ulx/lua/ulx/modules/slots.lua). I'm running reserved slots mode 3 (only have one slot open and kick players that doesn't have reserved slot access when the server is full).
The code now looks like this (I added some print()'s on line 10, 13 and 42):
local function playerAccess( ply )
local mode = GetConVarNumber( "ulx_rslotsMode" )
if mode == 0 then return end -- Off!
local visible = util.tobool( GetConVarString( "ulx_rslotsVisible" ) )
local slots = calcSlots()
local cur = #player.GetAll()
local max = game.MaxPlayers()
print("Checking player " .. ply:Name() .. "...")
if ply:query( access ) then -- If they have access, handle this differently
print("Player " .. ply:Name() .. " has reserved slot access")
if not visible then -- Make sure our visible slots is up to date
updateSlots()
end
if mode == 3 and cur + slots > max then -- We've got some kicking to do!
local shortestply
local shortesttime = math.huge
local players = player.GetAll()
for _, player in ipairs( players ) do
if not ULib.ucl.query( player, access ) then
if player:TimeConnected() < shortesttime then
shortesttime = player:TimeConnected()
shortestply = player
end
end
end
if not shortestply then -- We've got a server filled to the brim with admins? Odd but okay
return
end
ULib.kick( shortestply, "[ULX] Freeing slot. Sorry, you had the shortest connection time." )
end
return
end
print("Player " .. ply:Name() .. " doesn't have reserved slot access")
if cur + slots > max then
ULib.queueFunctionCall( ULib.kick, ply, "[ULX] Reserved slot, sorry!" ) -- Wait a frame so all access hooks can be called properly.
end
end
hook.Add( ULib.HOOK_UCLAUTH, "ULXReservedSlots", playerAccess, 20 ) -- Run at the end of auth
This is what happens when players without reserved slot access joins:
Checking player a shoe...
Player a shoe doesn't have reserved slot access
Checking player Cookie...
Player Cookie doesn't have reserved slot access
Checking player Chimera...
Player Chimera doesn't have reserved slot accessAnd this happens when players with access join:
Checking player YankingDeez...
Player YankingDeez doesn't have reserved slot access
Checking player YankingDeez...
Player YankingDeez has reserved slot access
Checking player | palsternacka...
Player | palsternacka doesn't have reserved slot access
Checking player | palsternacka...
Player | palsternacka has reserved slot accessWhich means that the first time the ULib.HOOK_UCLAUTH hook runs, the reserved slot access players doesn't have access and therefore they get kicked if the server is full.
Should I file a bug report or did I do something wrong? Thanks in advance for any help!