Eistee Posted November 10, 2013 Share Posted November 10, 2013 Hello, how I make a smooth intro with pictures? Its jerk when i do it with timers.. Link to comment
xXMADEXx Posted November 10, 2013 Share Posted November 10, 2013 use the event onClientRender or onClientPreRender. (onClientPreRender will probably be better.) Link to comment
Eistee Posted November 10, 2013 Author Share Posted November 10, 2013 Can you give me an example with 2 Pictures? Please Link to comment
tosfera Posted November 10, 2013 Share 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 Link to comment
Eistee Posted November 10, 2013 Author Share 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) Link to comment
./BlackBird# Posted November 10, 2013 Share 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); Link to comment
Eistee Posted November 10, 2013 Author Share Posted November 10, 2013 Thank you! How I can make an addCommandHandler on this function? Link to comment
./BlackBird# Posted November 10, 2013 Share 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) Link to comment
Eistee Posted November 15, 2013 Author Share 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. Link to comment
Dealman Posted November 15, 2013 Share Posted November 15, 2013 Why get the screen resolution with every frame? Enough doing it only once. Link to comment
Eistee Posted November 15, 2013 Author Share Posted November 15, 2013 Its okay so Now i need it so that the pictures start to play when i am sprinting Link to comment
denny199 Posted November 15, 2013 Share Posted November 15, 2013 Use: https://wiki.multitheftauto.com/wiki/GetPedMoveState Link to comment
Eistee Posted November 15, 2013 Author Share 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); Link to comment
Castillo Posted November 15, 2013 Share Posted November 15, 2013 What do you mean by "import"? Link to comment
denny199 Posted November 15, 2013 Share 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 Link to comment
Eistee Posted January 24, 2014 Author Share 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? Link to comment
Castillo Posted January 24, 2014 Share Posted January 24, 2014 Yes, you can use one of these events. Link to comment
Eistee Posted January 24, 2014 Author Share 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 ) Link to comment
Eistee Posted January 24, 2014 Author Share Posted January 24, 2014 Many thanks in advance Link to comment
McDeKi Posted January 25, 2014 Share 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 Link to comment
Eistee Posted January 26, 2014 Author Share Posted January 26, 2014 Thats the problem. Interval is below 50. Link to comment
denny199 Posted January 26, 2014 Share 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.. Link to comment
Eistee Posted January 26, 2014 Author Share 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 ) 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