Blocking kill command

I wanna block the kill command, i’ve tryed to work on something but i doesn’t work:


function AntiKill()
	if LocalPlayer():concommand.Run( "kill" ) then
	LocalPlayer():ChatPrint("If you have a problem do @ message here!")
	return false
	end
end

hook.Add("Think", "Test", AntiKill)

Can anybody tell me what i did wrong?

  • Thanks

PlayerCanSuicide

Can’t make it work, can you please post what i should do?


hook.Add("CanPlayerSuicide", "nosuicides_damnit",function(ply)
return false
end)

You can use the actual function instead of using hooks

[lua]
function GM:CanPlayerSuicide( ply )
ply:ChatPrint(“You can’t suicide, If you have a problem do @ message here!”)
return false
end

[/lua]

[editline]1st June 2013[/editline]


hook.Add("Think", "Test", AntiKill)

Also why use think?

-snip-

Just make a file called whatever.lua put it in lua/autorun/server and than add this to it:


hook.Add("CanPlayerSuicide", "RestrictPlayerSuicide", function(ply)
		ply:ChatPrint("You are unable to suicide.")
		return false
end)

Yeah, let’s repeat my post again and again.

-snip-

You cannot remove console commands, a lot of coders tried to do this with lua_openscript_cl but it failed. You can only use this to remove LUA concommands.

You could do this clientside by detouring functions like RunConsoleCommand and ConCommand

Holy crap just use a flipping hook as mention 9000 times in this thread. No need to detour or anything.

How does that work, could you send give a link or get an example please?

It won’t stop people from typing kill in their consoles.

It doesn’t disable people from doing it in console. I didn’t read your above code and assumed you just did not want it ran on you by a lua script.

Actually your code is wrong; the hook’s name is CanPlayerSuicide.

It took it from wizards post, so don’t blame me. It doesn’t even matter, because the answers is given, someone close the damn thread already…

But yeah, OP should mark it as solved. (hint hint)


(User was banned for this post ("backseat moderation" - Gran PC))