A script that binds rp_toggleholster to...

looking for a script that forces the client to binds RP_Toggleholster to the Delete key

[lua]hook.Add(“Think” , “keypress” , function() if input.IsKeyDown(73) then RunConsoleCommand(“RP_Toggleholster”) end end )[/lua]

You’ll need to do some checks to make sure it’s been pressed once, not multiple times or whatever, checking for key presses is dodgy.

[lua]
local downLast = false
hook.Add(“Think” , “keypress” , function()

if input.IsKeyDown(73) then

    if !downLast then 

        RunConsoleCommand("RP_Toggleholster") 
    end

    downLast = true 
else

    downLast = false
end

end )
[/lua]

Added what FlapJack described to his code.

You should use KEY_DELETE instead of 73. This makes the code easier to read, and it would still work if garry changes the KEY-enumerations.

So you mean like this?
[lua]local downLast = false
hook.Add(“Think” , “keypress” , function()

if input.IsKeyDown(KEY_DELETE) then  

    if !downLast then   

        RunConsoleCommand("RP_Toggleholster")   
    end  

    downLast = true   
else  

    downLast = false  
end  

end ) [/lua]

Oh sorry for taking the entire code, I just wanted to be sure, cause I need something like this too.

Yes, it would work.

Wouldn’t it work if in the console you typed


 
Bind key_del "rp_toggleholster"