Author Topic: Restrict spawnnpc in sandbox  (Read 1682 times)

0 Members and 3 Guests are viewing this topic.

Offline Avoid

  • Full Member
  • ***
  • Posts: 142
  • Karma: 42
Restrict spawnnpc in sandbox
« 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

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Restrict spawnnpc in sandbox
« Reply #1 on: June 17, 2014, 09:46:00 PM »
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.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Cobalt

  • Full Member
  • ***
  • Posts: 216
  • Karma: 44
  • http://steamcommunity.com/id/__yvl/
Re: Restrict spawnnpc in sandbox
« Reply #2 on: June 17, 2014, 09:50:12 PM »
What kind of gamemode is it?