• CanKeyPress (Client)
    3 replies, posted
Whipped this up, but I don't know if anyone would want to use this. [lua]function PostKey(ucmd) //Msg(tostring(ucmd:GetButtons()).."\n") 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()).."\n") 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:
Sorry, you need to Log In to post a reply to this thread.