How do you disable the kill command?

Hi guys Is there some sort of way too disable the kill and explode console commands on a Gmod server? Thanks

With lua. I’d give you a small lua script but I don’t know how to do it myself.

For Kill, here’s an example.

[lua]function GM:CanPlayerSuicide( pl )
//Whatever goes here
return false;
end[/lua]

Or if you was to install assmod it comes with that.


function GM:CanPlayerSuicide(ply)
	ply:ChatPrint("Stuck? Good luck getting out.")
	return false
end

God I hate that :V
Edit:
Now that I think about it, I did know how to make that. I just didn’t think of the CanPlayerSuicide thing and I was thinking about blocking the console command itself (Which I don’t know how to do… yet).

[editline]07:25PM[/editline]

Hey we didn’t tell him where to put it!

  1. Go to

garrysmod/lua/autorun/server/

  1. Make a new file called whatever you want.
  2. Change its file type to .lua.
  3. Open it with notepad.
  4. Copy/paste the code.
  5. Save & Close it.
    (7. Launch Gmod
  6. Use an admin mod to teleport people inside walls and disable noclip
  7. Have fun with them yelling “WTF AARGH FFFFFFFFFUUU” in the mic.
  8. ???
  9. Profit)

Didn’t work.

[editline]02:52PM[/editline]

what do i do now?

[editline]02:52PM[/editline]

what do i do ? if its not working

You don’t need to quote the same thing twice. Are you sure you changed its file type to .lua?


Wait never mind I can fix it for you.
Here

Just put that in your main GMod directory

Its still not working :slight_smile:

Testing it myself.

[editline]12:23AM[/editline]

You’re right. Didn’t work. But I fixed it. Copy/paste this into the file:


local function BlockSuicide(ply)
	ply:ChatPrint("Stuck? Good luck getting out.")
	return false
end
hook.Add( "CanPlayerSuicide", "BlockSuicide", BlockSuicide )