DarkByte Posted August 4, 2016 Posted August 4, 2016 Hello, I'm using interpolateBetween in my hud, it's working like a loading bar forward but it doesn't use the animation backwards, help? When I hear someone saying Mac is better than PC. w0t?w0t? w0t? Great minds discuss ideas, average minds discuss events and small minds discuss people.
Bonus Posted August 4, 2016 Posted August 4, 2016 Let the fProgress go from 1 to 0. Like that: local animcoming = true local progstart = 0 local function drawThatAnim ( ) local progress = 0 if animcoming then progress = (getTickCount()-progstart)/5000 if progress >= 2 then animcoming = false progstart = getTickCount()+1050 end else progress = ( progstart - getTickCount() ) / 5000 end local x, y = interpolateBetween ( 0, 0, 0, 1000, 1000, 0, progress, "Linear" ) dxDrawRectangle ( x, y, 10, 10, tocolor ( 255, 0, 0 ), true ) end function stopAnimDraw ( ) removeEventHandler ( "onClientRender", root, drawThatAnim ) end addCommandHandler ( "startanim", function ( ) animcoming = true progstart = getTickCount() addEventHandler ( "onClientRender", root, drawThatAnim ) end )
DarkByte Posted August 5, 2016 Author Posted August 5, 2016 I've made this, it won't go backwards using animation only forward. local lenghtHPC = interpolateBetween(0,0,0,lenghtHPC,0,0, (now - start) / ((start + 5000) - start), "OutQuad") When I hear someone saying Mac is better than PC. w0t?w0t? w0t? Great minds discuss ideas, average minds discuss events and small minds discuss people.
Moderators IIYAMA Posted August 5, 2016 Moderators Posted August 5, 2016 1 - Progress = invert Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
DarkByte Posted August 5, 2016 Author Posted August 5, 2016 It keeps decreasing, not stopping at the needed value. When I hear someone saying Mac is better than PC. w0t?w0t? w0t? Great minds discuss ideas, average minds discuss events and small minds discuss people.
Bonus Posted August 5, 2016 Posted August 5, 2016 Oh, I forgot to use stopAnimDraw: local animcoming = true local progstart = 0 local function drawThatAnim ( ) local progress = 0 if animcoming then progress = (getTickCount()-progstart)/5000 if progress >= 2 then animcoming = false progstart = getTickCount()+1050 end else progress = ( progstart - getTickCount() ) / 5000 if progress >= 1 then -- NEW stopAnimDraw() -- NEW return -- NEW end -- NEW end local x, y = interpolateBetween ( 0, 0, 0, 1000, 1000, 0, progress, "Linear" ) dxDrawRectangle ( x, y, 10, 10, tocolor ( 255, 0, 0 ), true ) end function stopAnimDraw ( ) removeEventHandler ( "onClientRender", root, drawThatAnim ) end addCommandHandler ( "startanim", function ( ) animcoming = true progstart = getTickCount() addEventHandler ( "onClientRender", root, drawThatAnim ) end )
DarkByte Posted August 5, 2016 Author Posted August 5, 2016 I was saying that to IIYAMA When I hear someone saying Mac is better than PC. w0t?w0t? w0t? Great minds discuss ideas, average minds discuss events and small minds discuss people.
Moderators IIYAMA Posted August 5, 2016 Moderators Posted August 5, 2016 if progress <= 0 then progress = 0 -- + stop it. end Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
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