Reserved slot for admin/superadmin (Reguler Garry admin mod)
4 replies, posted
Hey How I can do Reserved slot for admin/superadmin (Reguler Garry admin mod)
I will set the server slots to 50 but it will show 40 and the 10 slots will be reserved for admins/custom user group.
You can't do this without custom admin mods.
[QUOTE=Robotboy655;47457542]You can't do this without custom admin mods.[/QUOTE]
I can create custom script for that ?
You will have to make one for the "slot reserved" stuff.
You can set visible maxplayers by using the server console variable "sv_visiblemaxplayers 40"
You could hook into CheckPassword, check to see if you have reached the max number of reserved slots, and then check to see if the player is admin. Here's something I made quickly while trying not to fall asleep. This is not tested and may not work, but it will show you the general concept.
[code]
-- Put the number of reserved slots here. It will be subracted from the maximum amount of players.
local ReservedSlots = 10
local NonReservedSlots = cvars.Number('maxplayers') - ReservedSlots
-- Put whatever ranks you want to be reserved here. The template is: ['usergrouphere'] = true.
-- Make sure to separate entries in the table with a comma.
local ReservedRanks = {
['admin'] = true,
['superadmin'] = true
}
if SERVER then
-- Set the visible amount of players to whatever the non-reserved slot is. (Thanks robotboy)
game.ConsoleCommand('sv_visiblemaxplayers '..tostring(NonReservedSlots))
function ShouldLimitPlayers()
-- Pretty simple. Checks if the amount of online players is at or greater than the amount of Non-Reserved slots.
if #player.GetAll() >= NonReservedSlots then
return true
end
return false
end
function IsReservedRank(sid64)
-- The CheckPassword hook does not contain a player argument, so you can't use Player:GetUserGroup() or Player:IsUserGroup().
-- You have to search through the table of all users with a group to see if the connecting user is an admin.
-- It uses SteamID64, so you need to convert it.
local ranktable = util.GetUserGroups()[util.SteamIDFrom64(sid64)]
if ranktable and ReservedRanks[ranktable.group] then
return true
end
return false
end
hook.Add('CheckPassword', 'DisallowPlayerJoin', function(sid64, ip, svpass, clpass, name)
if ShouldLimitPlayers() and not IsReservedRank(sid64) then
-- Change the string below to whatever message you want to be displayed to non-reserved players who are disconnected.
return false, 'The remaining slots are reserved. '..tostring(#player.GetAll())..'/'..tostring(cvars.Number('maxplayers'))
end
end)
end
[/code]
Sorry, you need to Log In to post a reply to this thread.