Jump to content

Simulate player pulling up over a wall on jump


Recommended Posts

Hi again. I wrote a "new jump height" function to see if I can get the hang of MTA's functions and of Lua. My function doesn't want to force the player to grab the edge of a wall, any ideas what I need to do?

jumpTimer = 0 
isJumping = 0 
NEW_JUMP_HEIGHT = 2 
function setVelocity(player) 
    if (isJumping==0) then 
        isJumping = 1 
        setPedAnimation(player, "ped","JUMP_glide", -1, false, true) 
        jumpTimer = setTimer(jumpCounter, 50, 0, player) 
    end 
end 
oldJumpHeight = 0.0 
function jumpCounter(player) 
    if (isJumping == 1) then 
        outputDebugString("Playing is jumping") 
        x, y, z = getElementVelocity(player) 
        setElementVelocity(player, x, y, 0.2) 
        if (oldJumpHeight>=NEW_JUMP_HEIGHT) then 
            outputDebugString("Height peaked. Velocity="..z) 
            isJumping = 2 
            oldJumpHeight = 0.0 
        else 
            oldJumpHeight = oldJumpHeight + 0.4 
        end 
    elseif (isJumping == 2) then 
        x, y, z = getElementVelocity(player) 
        if ((z<=-0.10) or (z==0)) then 
            setPedAnimation(player, "ped") 
            isJumping = 0 
            killTimer(jumpTimer) 
        end 
    end 
end 

Link to comment

Take a quick check about the velocities and animations and tasks using the following functions:

  
getPedTask() 
getPedSimplestTask() 
getElementVelocity() 
getPedAnimation() 
setTimer() / addEventHandler("onClient(Pre)Render"...) 
  

Use someone of those functions (in rough format) to see what occurs when.

Link to comment
  • 2 weeks later...

the problem is that your setting animations, when setting the control state is the only thing I was successful in making peds or players grab ledges or hop fences. (force the player to jump by setting the jump control state)

Link to comment

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...