Ulysses

General => Developers Corner => Topic started by: Avoid on June 17, 2014, 11:13:11 AM

Title: Restrict spawnnpc in sandbox
Post by: Avoid on June 17, 2014, 11:13:11 AM
Hello guys,
to learn some more Lua and how GMod functions I have decided to start writing my own small gamemode.
Since it derives from sandbox users can use all sandbox functions. I went on and disabled the context menu aswell as the spawnmenu (qmenu)

Code: [Select]
local function DisallowSpawnMenu( )
if not LocalPlayer():IsAdmin() then
return false
end
end
 
hook.Add( "SpawnMenuOpen", "DisallowSpawnMenu", DisallowSpawnMenu)

local function DisallowContextMenu( )
if not LocalPlayer():IsAdmin() then
return false
end
end
 
hook.Add( "OnContextMenuOpen", "DisallowContextMenu", DisallowContextMenu)

But I just noticed users can still use gmod_spawnnpc and gmod_npcweapon, now I want to disable this aswell.
My question is where I should start looking and how to effectively disable those two commands.

Cheers,
Avoid
Title: Re: Restrict spawnnpc in sandbox
Post by: JamminR on June 17, 2014, 09:46:00 PM
Hook.
Player:SpawnNPC (http://wiki.garrysmod.com/page/SANDBOX/PlayerSpawnNPC)
Might help with npcweapon too, but there's other hooks in that area for spawning stuff(and it's prevention). Sweps, objects, sents.
Poke around unless someone answers more exact.
Title: Re: Restrict spawnnpc in sandbox
Post by: Cobalt on June 17, 2014, 09:50:12 PM
What kind of gamemode is it?