General > Developers Corner

Restrict spawnnpc in sandbox

(1/1)

Avoid:
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: ---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)

--- End code ---

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

JamminR:
Hook.
Player:SpawnNPC
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.

Cobalt:
What kind of gamemode is it?

Navigation

[0] Message Index

Go to full version