falseprophet Posted July 8, 2011 Share Posted July 8, 2011 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
qaisjp Posted July 8, 2011 Share Posted July 8, 2011 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
Slothman Posted July 20, 2011 Share Posted July 20, 2011 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
qaisjp Posted July 20, 2011 Share Posted July 20, 2011 You could try lagging the server by using 100 setTimer's and setPedAnimations.. 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