CanKeyPress (Client)

Whipped this up, but I don’t know if anyone would want to use this.
[lua]function PostKey(ucmd)
//Msg(tostring(ucmd:GetButtons())…"
")
local i=0
local buttons = ucmd:GetButtons()
for i=0,24 do
if ucmd:GetButtons() & 2^i > 0 then
if CanKeyPress(2^i) then
buttons = buttons - 2^i
end
end
end
end
ucmd:SetButtons(buttons)
end
hook.Add(“CreateMove”,“PostKey”,PostKey)

function CanKeyPress(inkey)
return true
end[/lua]

How to cancel a person attempting to attack:
[lua]
function CanKeyPress(inkey)
if inkey == IN_ATTACK then
return false
end
return true
end
[/lua]

If you make it into a hook it would be much more useful.

was going to, but that never worked out.

[lua]function PostKey(ucmd)
//Msg(tostring(ucmd:GetButtons())…"
")
local i=0
local buttons = ucmd:GetButtons()
for i=0,24 do
if ucmd:GetButtons() & 2^i > 0 then
if gamemode.Call(“CanKeyPress”,2^i) then
buttons = buttons - 2^i
end
end
end
end
ucmd:SetButtons(buttons)
end
hook.Add(“CreateMove”,“PostKey”,PostKey)

function Hook(inkey)
return true
end

hook.Add(“CanKeyPress”,Hook)[/lua]

There, if you don’t mind:v: