Blocking numpad keys

Hello. How to prevent using numpad keys for opening fading doors?


How are you supposed to open it then?

He probably just wants it to open through the button or keypad tool, rather than players using their numpad.

But keypads/buttons are using numpad to open the fading door? (I think)

Dude. Stop it. Try to learn lua a bit. Your every message, is a message “make for me please”.
Just google your question -> Find thread with code of that -> If that broken -> Repair that -> If not -> Enjoy your self. Thats not a forum “Make for me awesome DarkRP server…”.
You like creating 3 threads/messages about to help you with your DarkRP. That so mean…
If you just need to know how - Hook Iskeypressed then check is that your key (numpad1 etc) and return false. THATS ALL

P.S. If someone think that I’m dumb look at his post/threads history. That insane. Btw he was need hook, as he said in skype chat, but still rate me dumb :smiley:


Are you aware of key related hooks/functions such as the examples here Take a look on the wiki and see if you can find something that helps you along.

I feel the reason you were rated dumb is because the way you worded your post is awful to read.

You could possibly hook into PlayerBindPress or KeyPress ( Keypress returns the KEY number ), and determine the key which was pressed.

I found some code through a Google search on the first page:

I did a quick test, it seemed to stop some of the commands from running but not all. I rewrote it slightly for it to work.

[lua]hook.Add(“KeyPress”, “AntiCheat:KeyPress”, function( _p, _key )
print( Player, _key )
if ( _p:KeyDown( KEY_PAD_0 ) || _p:KeyDown( KEY_PAD_1 ) || _p:KeyDown( KEY_PAD_2 ) || _p:KeyDown( KEY_PAD_3 ) || _p:KeyDown( KEY_PAD_4 ) ||
_p:KeyDown( KEY_PAD_5 ) || _p:KeyDown( KEY_PAD_6 ) || _p:KeyDown( KEY_PAD_7 ) || _p:KeyDown( KEY_PAD_8 ) || _p:KeyDown( KEY_PAD_9 ) ||
_p:KeyDown( KEY_PAD_DIVIDE ) || _p:KeyDown( KEY_PAD_MULTIPLY ) || _p:KeyDown( KEY_PAD_MINUS ) ||
_p:KeyDown( KEY_PAD_PLUS ) || _p:KeyDown( KEY_PAD_ENTER ) || _p:KeyDown( KEY_PAD_DECIMAL )
) then
_p:ChatPrint(“Numpad is disabled.”)
return false;
end )
concommand.Remove( “+gm_special” );
concommand.Remove( “-gm_special” );
concommand.Add( “+gm_special”, function( _p ) _p:ChatPrint( “Numpad is disabled!” ) end );
concommand.Add( “-gm_special”, function( ) end );[/lua]

+/-gm_special isn’t used anymore. Instead, the numpad library is ( ). This allows for use of any key instead of just numpad keys (despite the name).

Callbacks for keypresses can be added using numpad.OnDown and numpad.OnUp whilst the keypresses themselves are sent to the library with the numpad.Activate and numpad.Deactivate functions. These functions are called by the button sent, the keypad sent and also the sandbox gamemode’s following code:
These are buttons that the client is pressing. They’re used
in Sandbox mode to control things like wheels, thrusters etc.
function GM:PlayerButtonDown( ply, btn )

    numpad.Activate( ply, btn )


These are buttons that the client is pressing. They’re used
in Sandbox mode to control things like wheels, thrusters etc.
function GM:PlayerButtonUp( ply, btn )

    numpad.Deactivate( ply, btn )


So it seems that you ~could~ just remove these functions in a shared file, but I’m not sure if anything else relies on them. Here’s the code for that:

– (autorun/something.lua)
hook.Add(“Initialize”, “NumpadOverride”, function()
GAMEMODE.PlayerButtonDown = function() end
GAMEMODE.PlayerButtonUp = function() end

Note: This is gonna stop numpad keys working for everything that uses them. Not just doors.

Wow, those two functions PlayerButtonUp/Down are fantastic. I think I can recode my binds manager using them and be much more responsive. Right now I use 2 different hooks plus I rely on other authentication because mousewheel and other things would screw up. This seems to work reliably.