Jump to content

check jump

Recommended Posts

function playerPressedKey(button, press)
    if (button == "lshift" and press) then
	if getPedControlState(localPlayer,"jump") == true then
		outputChatBox("jump", 0, 255, 0)
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 post
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
            jump = true
        elseif not getPedControlState(localPlayer, "jump") and jump then
            jump = false

        tick = getTickCount()

So you can detect, regardless of the key that the player presses.

  • Like 1
Link to post

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...