Disabling numpad


I’m trying to disable the use of numpad entirely.

I’m assuming it’s something to do with this kind thing:

function KeyPressed (ply, key)    
	if (	ply:KeyDown(KEY_PAD_0) or
			ply:KeyDown(KEY_PAD_1) or
			ply:KeyDown(KEY_PAD_2) or
			ply:KeyDown(KEY_PAD_3) or
			ply:KeyDown(KEY_PAD_4) or
			ply:KeyDown(KEY_PAD_5) or
			ply:KeyDown(KEY_PAD_6) or
			ply:KeyDown(KEY_PAD_7) or
			ply:KeyDown(KEY_PAD_8) or
			ply:KeyDown(KEY_PAD_9) or
			ply:KeyDown(KEY_PAD_DIVIDE) or
			ply:KeyDown(KEY_PAD_MULTIPLY) or
			ply:KeyDown(KEY_PAD_MINUS) or
			ply:KeyDown(KEY_PAD_PLUS) or
			ply:KeyDown(KEY_PAD_ENTER) or
			ply:KeyDown(KEY_PAD_DECIMAL) ) then
		ply:ChatPrint("Numpad is disabled.")
		return false
 hook.Add( "KeyPress", "KeyPressedHook", KeyPressed )

I know that isn’t going to work, but I’m stuck on this one and don’t really know what to do.

Any help would be appreciated.


I don’t know if it works, but if it would work then you should return true after the first end to enable all other keys.

Working one:

concommand.Remove( “+gm_special” )
concommand.Remove( “-gm_special” )
concommand.Add( “+gm_special”, function( ply ) ply:ChatPrint( “Numpad is disabled!” ) end )
concommand.Add( “-gm_special”, function() end ) – to avoid errors,

Thank you, that worked.

Sorry for double post, but although that code works, it isn’t going to work for the purpose I’m using it for.

Which is to disable players using their numpads and only allow them to use keypads/buttons. Keypads seem to use the gm_special to activate the key (Owner:ConCommand("-gm_special “…Key…”

I think it would be easier to get my above code to work than recode keypad.

So any idea how to get that to work?


well. not quite . your pretty much half way there for what you want . all you have to do is edit a couple of things.

befor i tell you how let me just inform you that when a gmod update comes along your gonna have to overwrite the numpad.lua file

that said open up numpad.lua it should be in garrysmod\lua\includes\modules

from there your gonna have to edit the concommand gm_special to something different on line
215 and 216

then your gonna have to edit your keypad init.lua and change the gm_special concommand to the one you changed in the numpad.lua file

from there all you have to do is run your script you have on the thread and your players on your server wont be able to use the numpad but will be able to use the keypad on fading doors. it worked on my server . good luck