mcer Posted June 17, 2013 Posted June 17, 2013 Little Q: How I can make a function repeat without using the "SetTimer"?.
mcer Posted June 17, 2013 Author Posted June 17, 2013 What is it? I want to make an animation. If I use what you mentioned, the animation is repeated before the time of completion.
Castillo Posted June 17, 2013 Posted June 17, 2013 You don't have to use anything else but setPedAnimation to make it repeat, just set the repeat argument.
mcer Posted June 17, 2013 Author Posted June 17, 2013 You don't have to use anything else but setPedAnimation to make it repeat, just set the repeat argument. See the code function playerDamagehelp() local getdamage = getElementHealth ( getLocalPlayer() ) if getdamage < 21 then local playeranimdamage = getLocalPlayer() setPedAnimation( playeranimdamage, "beach", "bather") else local playeranimdamages = getLocalPlayer() setPedAnimation(playeranimdamages,false) end end addEventHandler("onClientRender", getRootElement(), playerDamagehelp)
Castillo Posted June 17, 2013 Posted June 17, 2013 setPedAnimation ( playeranimdamage, "beach", "bather", -1, true ) Use that instead.
mcer Posted June 17, 2013 Author Posted June 17, 2013 setPedAnimation ( playeranimdamage, "beach", "bather", -1, true ) Use that instead. Same problem. Repeat in less than a second, is not expected until the end of the animation.
iPrestege Posted June 17, 2013 Posted June 17, 2013 (edited) What's the problem if using the timer in the client side? Edited June 17, 2013 by Guest
Castillo Posted June 17, 2013 Posted June 17, 2013 setPedAnimation ( playeranimdamage, "beach", "bather", -1, true ) Use that instead. Same problem. Repeat in less than a second, is not expected until the end of the animation. The loop argument will repeat it after it ended.
mcer Posted June 17, 2013 Author Posted June 17, 2013 Example: The animation duration is 5 seconds It is repeated at the second 0.2
mcer Posted June 17, 2013 Author Posted June 17, 2013 setPedAnimation ( playeranimdamage, "beach", "bather", -1, true ) Use that instead. Same problem. Repeat in less than a second, is not expected until the end of the animation. The loop argument will repeat it after it ended. I know, but i have this problem with or without "true"
Castillo Posted June 17, 2013 Posted June 17, 2013 Try this: setPedAnimation ( playeranimdamage, "beach", "bather", 5000, true )
mcer Posted June 17, 2013 Author Posted June 17, 2013 Try this: setPedAnimation ( playeranimdamage, "beach", "bather", 5000, true ) Same
iPrestege Posted June 17, 2013 Posted June 17, 2013 Use a timer there's no problem if it's a client side.
mcer Posted June 17, 2013 Author Posted June 17, 2013 i used that, But i want when the player have less than 20 of health the anim start.
iPrestege Posted June 17, 2013 Posted June 17, 2013 addEventHandler('onClientResourceStart',resourceRoot, function ( ) setTimer ( function ( ) local anim = {getPedAnimation( localPlayer )} if getElementHealth ( localPlayer ) <= 20 then if not ( anim[1] == "beach" and anim[2] =="bather" ) then setPedAnimation ( localPlayer, "beach", "bather", -1, true, true, false ) end else if ( anim[1] == "beach" and anim[2] == "bather" ) then setPedAnimation( localPlayer, false) end end end,500,0 ) end ) Try this.
mcer Posted June 17, 2013 Author Posted June 17, 2013 addEventHandler('onClientResourceStart',resourceRoot, function ( ) setTimer ( function ( ) local anim = {getPedAnimation( localPlayer )} if getElementHealth ( localPlayer ) <= 20 then if not ( anim[1] == "beach" and anim[2] =="bather" ) then setPedAnimation ( localPlayer, "beach", "bather", -1, true, true, false ) end else if ( anim[1] == "beach" and anim[2] == "bather" ) then setPedAnimation( localPlayer, false) end end end,500,0 ) end ) Try this. Worked!!, Thanks!
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