mcer Posted June 17, 2013 Share Posted June 17, 2013 Little Q: How I can make a function repeat without using the "SetTimer"?. Link to comment
mcer Posted June 17, 2013 Author Share Posted June 17, 2013 I tryied, but i have problems. Link to comment
mcer Posted June 17, 2013 Author Share 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. Link to comment
Castillo Posted June 17, 2013 Share Posted June 17, 2013 You don't have to use anything else but setPedAnimation to make it repeat, just set the repeat argument. Link to comment
mcer Posted June 17, 2013 Author Share 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) Link to comment
Castillo Posted June 17, 2013 Share Posted June 17, 2013 setPedAnimation ( playeranimdamage, "beach", "bather", -1, true ) Use that instead. Link to comment
mcer Posted June 17, 2013 Author Share 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. Link to comment
iPrestege Posted June 17, 2013 Share Posted June 17, 2013 (edited) What's the problem if using the timer in the client side? Edited June 17, 2013 by Guest Link to comment
Castillo Posted June 17, 2013 Share 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. Link to comment
mcer Posted June 17, 2013 Author Share Posted June 17, 2013 Example: The animation duration is 5 seconds It is repeated at the second 0.2 Link to comment
mcer Posted June 17, 2013 Author Share 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" Link to comment
Castillo Posted June 17, 2013 Share Posted June 17, 2013 Try this: setPedAnimation ( playeranimdamage, "beach", "bather", 5000, true ) Link to comment
mcer Posted June 17, 2013 Author Share Posted June 17, 2013 Try this: setPedAnimation ( playeranimdamage, "beach", "bather", 5000, true ) Same Link to comment
iPrestege Posted June 17, 2013 Share Posted June 17, 2013 Use a timer there's no problem if it's a client side. Link to comment
mcer Posted June 17, 2013 Author Share Posted June 17, 2013 i used that, But i want when the player have less than 20 of health the anim start. Link to comment
iPrestege Posted June 17, 2013 Share 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. Link to comment
mcer Posted June 17, 2013 Author Share 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! 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