Eistee Posted November 10, 2013 Posted November 10, 2013 Hello, how I make a smooth intro with pictures? Its jerk when i do it with timers..
xXMADEXx Posted November 10, 2013 Posted November 10, 2013 use the event onClientRender or onClientPreRender. (onClientPreRender will probably be better.) The Ultimate Lua Tutorial! | MTA PHP SDK
Eistee Posted November 10, 2013 Author Posted November 10, 2013 Can you give me an example with 2 Pictures? Please
tosfera Posted November 10, 2013 Posted November 10, 2013 Not tested, it is just a brainfart. local images = { "image1", "image2", "image3" } function startIntro () drawPicture ( images[1] ); image = 1; addEventHandler ( "onClientRender", getRootElement(), drawPicture ); setTimer ( function() drawPicture ( images [ image + 1 ] ); image = image + 1; end, 5000, #images ); if ( image == #images ) then removeEventHandler ( "onClientRender", getRootElement(), drawPicture ); end end function drawPicture ( pictureName ) local x, y = guiGetScreenSize(); dxDrawImage ( 0, 0, x, y, "images/".. pictureName ..".png" ); end If you want to contact me directly concerning Advanced-Gaming, please contact me at [email protected]
Eistee Posted November 10, 2013 Author Posted November 10, 2013 local images = { "image1", "image2", "image3" } function startIntro () drawPicture ( images[1] ); image = 1; addEventHandler ( "onClientRender", getRootElement(), drawPicture ); setTimer ( function() drawPicture ( images [ image + 1 ] ); image = image + 1; end, 1000, #images ); if ( image == #images ) then removeEventHandler ( "onClientRender", getRootElement(), drawPicture ); end end function drawPicture ( pictureName ) local x, y = guiGetScreenSize(); dxDrawImage ( 0, 0, x, y, "images/".. pictureName ..".png" ); end function introstartt ( source, commandName ) startIntro () end addCommandHandler ( "intro", introstartt ) Error: Error: test\client.lua:19: attempt to concatenate local 'pictureName' (a nil value)
./BlackBird# Posted November 10, 2013 Posted November 10, 2013 local images = {"img1","img2","img3"} local n = 1 function draw() if not isTimer(timer) then timer = setTimer(function () n = n + 1 end,1000,1) end if n == #images then n = 1 end local x, y = guiGetScreenSize(); dxDrawImage ( 0, 0, x, y, "images/".. images[n]..".png" ); end addEventHandler ( "onClientRender", getRootElement(), draw); #~BlackBird~#
Eistee Posted November 10, 2013 Author Posted November 10, 2013 Thank you! How I can make an addCommandHandler on this function?
./BlackBird# Posted November 10, 2013 Posted November 10, 2013 local images = {"img1","img2","img3"} local n = 1 local show = false function draw() if not isTimer(timer) then timer = setTimer(function () n = n + 1 end,1000,1) end if n == #images then n = 1 end local x, y = guiGetScreenSize() dxDrawImage ( 0, 0, x, y, "images/".. images[n]..".png" ) end addCommandHandler("showImg", function () if show then removeEventHandler ( "onClientRender", getRootElement(), draw) else addEventHandler ( "onClientRender", getRootElement(), draw) end end) #~BlackBird~#
Eistee Posted November 15, 2013 Author Posted November 15, 2013 Thank you! And how i can play the pictures, when i sprint? (with getPedMoveState) And the pictures stop when i dont sprint.
Dealman Posted November 15, 2013 Posted November 15, 2013 Why get the screen resolution with every frame? Enough doing it only once. If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.
Eistee Posted November 15, 2013 Author Posted November 15, 2013 Its okay so Now i need it so that the pictures start to play when i am sprinting
denny199 Posted November 15, 2013 Posted November 15, 2013 Use: https://wiki.multitheftauto.com/wiki/GetPedMoveState Sometimes I dream about cheese
Eistee Posted November 15, 2013 Author Posted November 15, 2013 I know but how i can import this is the script? local images = {"img1","img2","img3"} local n = 1 function draw() if not isTimer(timer) then timer = setTimer(function () n = n + 1 end,1000,1) end if n == #images then n = 1 end local x, y = guiGetScreenSize(); dxDrawImage ( 0, 0, x, y, "images/".. images[n]..".png" ); end addEventHandler ( "onClientRender", getRootElement(), draw);
Castillo Posted November 15, 2013 Posted November 15, 2013 What do you mean by "import"? San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
denny199 Posted November 15, 2013 Posted November 15, 2013 (edited) local counter = 0 local starttick local currenttick local images = {"img1","img2","img3"} local x, y = guiGetScreenSize(); local secondBetweenImageInMS = 3000 addEventHandler("onClientRender",root, function() if getPedMoveState ( localPlayer ) == "sprint" then if not starttick then starttick = getTickCount() end currenttick = getTickCount() if currenttick - starttick >= secondBetweenImageInMS then counter = counter + 1 if counter == #images then counter = 1 end starttick = false end dxDrawImage ( 0, 0, x, y, "images/".. images[counter]..".png" ); end end ) Edited January 26, 2014 by Guest Sometimes I dream about cheese
Eistee Posted January 24, 2014 Author Posted January 24, 2014 Okay I have a little problem.. "Interval is below 50" How can i get 30ms? Every 30ms / one picture.. with onClientRender and onClientPreRender?
Castillo Posted January 24, 2014 Posted January 24, 2014 Yes, you can use one of these events. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Eistee Posted January 24, 2014 Author Posted January 24, 2014 Okay and then 30 ms will work? What i have to change? local countersprint = 1 local imagessprint = {"MW2Sprinten1","MW2Sprinten2","MW2Sprinten3","MW2Sprinten4","MW2Sprinten5","MW2Sprinten6","MW2Sprinten7","MW2Sprinten8","MW2Sprinten9","MW2Sprinten10","MW2Sprinten11","MW2Sprinten12","MW2Sprinten13","MW2Sprinten14","MW2Sprinten15","MW2Sprinten16","MW2Sprinten17","MW2Sprinten18","MW2Sprinten19","MW2Sprinten20","MW2Sprinten21","MW2Sprinten22","MW2Sprinten23","MW2Sprinten24","MW2Sprinten25","MW2Sprinten26"} local xsprint, ysprint = guiGetScreenSize(); local secondBetweenImageInMSsprint = 50 addEventHandler("onClientRender",root, function() if getPedMoveState ( localPlayer ) == "sprint" then if not isTimer(timer) then timer = setTimer(function () countersprint = countersprint + 1 end,secondBetweenImageInMSsprint,1) end if countersprint == #imagessprint then countersprint = 1 end local xsprint, ysprint = guiGetScreenSize(); dxDrawImage ( 0, 0, xsprint, ysprint, "images/sprint/".. imagessprint[countersprint]..".png" ); end end )
McDeKi Posted January 25, 2014 Posted January 25, 2014 local countersprint = 1 local imagessprint = {"MW2Sprinten1","MW2Sprinten2","MW2Sprinten3","MW2Sprinten4","MW2Sprinten5","MW2Sprinten6","MW2Sprinten7","MW2Sprinten8","MW2Sprinten9","MW2Sprinten10","MW2Sprinten11","MW2Sprinten12","MW2Sprinten13","MW2Sprinten14","MW2Sprinten15","MW2Sprinten16","MW2Sprinten17","MW2Sprinten18","MW2Sprinten19","MW2Sprinten20","MW2Sprinten21","MW2Sprinten22","MW2Sprinten23","MW2Sprinten24","MW2Sprinten25","MW2Sprinten26"} local xsprint, ysprint = guiGetScreenSize(); local secondBetweenImageInMSsprint = 30 addEventHandler("onClientRender",root, function() if getPedMoveState ( localPlayer ) == "sprint" then if not isTimer(timer) then timer = setTimer(function () countersprint = countersprint + 1 end,secondBetweenImageInMSsprint,1) end if countersprint == #imagessprint then countersprint = 1 end local xsprint, ysprint = guiGetScreenSize(); dxDrawImage ( 0, 0, xsprint, ysprint, "images/sprint/".. imagessprint[countersprint]..".png" ); end end ) local secondBetweenImageInMSsprint = 30
Eistee Posted January 26, 2014 Author Posted January 26, 2014 Thats the problem. Interval is below 50.
denny199 Posted January 26, 2014 Posted January 26, 2014 local counter = 1 local starttick local currenttick local images = {"img1","img2","img3"} local x, y = guiGetScreenSize(); local secondBetweenImageInMS = 3000 addEventHandler("onClientRender",root, function() if getPedMoveState ( localPlayer ) == "sprint" then if not starttick then starttick = getTickCount() end currenttick = getTickCount() if currenttick - starttick >= secondBetweenImageInMS then counter = counter + 1 if counter == (#images+1) then counter = 1 end starttick = false end dxDrawImage ( 0, 0, x, y, "images/".. images[counter]..".png" ); end end ) Don't use timers with onClientRender.... just use getTickCount.. Sometimes I dream about cheese
Eistee Posted January 26, 2014 Author Posted January 26, 2014 Do this work? local counter = 1 local starttick local currenttick local images = {"img1","img2","img3"} local x, y = guiGetScreenSize(); local secondBetweenImageInMS = 30 addEventHandler("onClientRender",root, function() if getPedMoveState ( localPlayer ) == "sprint" then if not starttick then starttick = getTickCount() end currenttick = getTickCount() if currenttick - starttick >= secondBetweenImageInMS then counter = counter + 1 if counter == (#images+1) then counter = 1 end starttick = false end dxDrawImage ( 0, 0, x, y, "images/".. images[counter]..".png" ); end end )
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