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