Disable spawnmenu apart from admins

Hello, well i would like to disable spawnmenu for anyone apart from admins. i have used the client side hooks shown on the gmod wiki gamemode hooks page but it doesnt work

does any know or done something similar?

local ply = LocalPlayer()
local function DisallowSpawnMenu( )
if ply:IsAdmin() then
return false
else return false
end

hook.Add( “SpawnMenuOpen”, “DisallowSpawnMenu”, DisallowSpawnMenu)

does it go in client side or server side or both?

[editline]06:42PM[/editline]

found it, its client sied :slight_smile:

It’s a serverside hook.

huh? really? so i can put it also in server side?

It is a clientside hook, and that code that was posted doesn’t even work. Try this:

[lua]hook.Add(“SpawnMenuOpen”, “adminonly”, function()
return LocalPlayer():IsAdmin();
end);[/lua]

[editline]06:12PM[/editline]

Or if you don’t want to stop all other SpawnMenuOpen hooks from running, use this:
[lua]hook.Add(“SpawnMenuOpen”, “adminonly”, function()
if LocalPlayer():IsAdmin() then
return true
end
end);[/lua]

Remember to AddCSLuaFile on the server otherwise it won’t take effect because they didn’t get the clientside file. Also it would be easy for someone with lua knowledge to disable this restriction if scriptenforcer isn’t enabled. If scriptenforcer is enabled then it would take extra steps, however this would be more trouble than it’s worth to use the spawn menu.

Extra steps?
just a bit of c++ lol

[editline]11:20PM[/editline]

] sv_scriptenforcer
“sv_scriptenforcer” = “2” ( def. “0” )
game archive notify replicated

  • Enforce script consistency
    ] lau_open autorun/client/baconbot.lua
    autorun/client/baconbot.lua run successfully!

He just needs to disable spawning serverside.

well its a lobby gamemode and i dont want people spawning anything or using toolguns so i thourght of disabling teh spawnmenu but there wasnt a server side hook :frowning:

Just go through all the PlayerSpawn hooks and return false (as well as gm_spawnsent, gm_spawnswep… etc).

For example:
[lua]hook.Add( “PlayerSpawnSWEP”, “DenySpawnSWEP”, function()
return false;
end );[/lua]

Or something along those lines.