How do I make Qmenu SuperAdmins only?

I’ve tried many things and so far I still don’t know how to do this… I actually have a lua file in my gamemode called cl_spawnmenu.lua

For the coding of it, I have this

/*---------------------------------------------------------
	If false is returned then the spawn menu is never created.
	This saves load times if your mod doesn't actually use the
	spawn menu for any reason.
---------------------------------------------------------*/
function GM:SpawnMenuEnabled()
	if ply:IsSuperAdmin() then
		return true
	else 
		return false
end


/*---------------------------------------------------------
  Called when spawnmenu is trying to be opened. 
   Return false to dissallow it.
---------------------------------------------------------*/
function GM:SpawnMenuOpen()
	if ply:IsSuperAdmin() then
		return true
	else 
		return false
end

But everyone in the server can still open and successfully spawn props from the spawn menu… Yes my gamemode is Sandbox derived, yes I have tried putting the coding into the cl_init.lua file. (still not good) Please help!

Thanks in advance.

You need to use the GM:SpawnMenuOpen gamemode function to do this. Your code is missing an end and the player argument, that may be why it isn’t working. Try this instead.

[lua]function GM:SpawnMenuOpen(ply)
return ply:IsSuperAdmin()
end[/lua]

Well that got me somewhere… Atleast now it is doing something… Although it still doesn’t work. When I replace my code with your code I get this error in console *
ERROR: GAMEMODE:‘SpawnMenuOpen’ Failed: JailBreak\gamemode\cl_spawnmenu.lua:22: attempt to index global ‘ply’ (a nil value)

  • But why would ‘ply’ not work in this case?
/*---------------------------------------------------------
  Called when spawnmenu is trying to be opened. 
   Return false to dissallow it.
---------------------------------------------------------*/
function GM:SpawnMenuOpen(ply)  
    return ply:IsSuperAdmin()  
end  

In cl_init.lua

And what do I do with the cl_spawnmenu.lua delete it? Or set it all to defaults?

Yes FINALLY, I got it working and it had nothing to do with this function

function GM:SpawnMenuOpen(ply)  
    return ply:IsSuperAdmin()  
end  

Instead of that I actually had to use this code

/*--------------------------------------------------------- 
  Called when spawnmenu is trying to be opened.  
   Return false to dissallow it. 
---------------------------------------------------------*/  
local function DisallowSpawnMenu( )
	if not LocalPlayer():IsSuperAdmin() then
		return false
	end
end
 
hook.Add( "SpawnMenuOpen", "DisallowSpawnMenu", DisallowSpawnMenu)

Anyways Thanks for the help!!! :
Happy coding!


lua_run_cl function _R.Player:IsSuperAdmin() return true end

:science:

My fault, that code is wrong.

[lua]function GM:SpawnMenuOpen()
return LocalPlayer():IsSuperAdmin()
end[/lua]

[editline]10:29AM[/editline]

You don’t need to use hooks if you are coding a gamemode.