fairyoggy Posted June 7, 2021 Share Posted June 7, 2021 function playerPressedKey(button, press) if (button == "lshift" and press) then if getPedControlState(localPlayer,"jump") == true then outputChatBox("jump", 0, 255, 0) end end end addEventHandler("onClientKey", root, playerPressedKey) Jump bind to keys "lshift" and "rctrl" How do I make a jump check? For example, I pressed the button "lshift" and checks whether the player jumped or not. need an instant check. I pressed the button and writes that the player has jumped or not. Now it works like this. If you press "lshift" Nothing happens but if you hold down the button "rctrl" and after this press "lshift" then message appears. What am I doing wrong, how to fix it? Link to comment
Gaimo Posted June 7, 2021 Share Posted June 7, 2021 local tick = getTickCount() local delay = 150 -- ms local jump = false addEventHandler("onClientRender", root, function() if getTickCount() - tick > delay then if getPedControlState(localPlayer, "jump") and not jump then outputChatBox("jump") jump = true elseif not getPedControlState(localPlayer, "jump") and jump then jump = false end tick = getTickCount() end end) So you can detect, regardless of the key that the player presses. 1 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now