• double tap
    5 replies, posted
How can I detect if a player has double tapped "w" real fast?
So KeyPress hook..except, I'm not sure how to set a variable with the CurTime() [editline]1st November 2010[/editline] [lua]hook.Add("KeyPress", "name", function(P, key) if key == KEY_W then --set variable?[/lua]
[lua] hook.Add("KeyPress","lol",function(ply,key) if key != IN_FORWARD then return end if ply.lastPress then if ply.lastPress+0.5 > CurTime() then --they double tapped W do something here ply.lastPress = nil --end the 'timer' (it will start again when they press W next time) else ply.lastPress = CurTime() --they didnt tap the second time fast enough so we reset the 'timer' end else ply.lastPress = CurTime() --start the tap 'timer' end end) [/lua]
Wow, thanks!
Please try to see the logic behind it before you use it, thank you:smile:
Sorry, you need to Log In to post a reply to this thread.