FuriouZ Posted April 28, 2013 Posted April 28, 2013 Hey ! I have an question, that how i can make that every 10 sec my loginpanel changes backround ? Hope that you guys understand me because i don't have very good english Anyway one shot is here :
iPrestege Posted April 28, 2013 Posted April 28, 2013 setTimer or "onClientRender" guiStaticImageLoadImage Use these functions .
FuriouZ Posted April 28, 2013 Author Posted April 28, 2013 setTimer or "onClientRender" guiStaticImageLoadImage Use these functions . Thanks,but if images images end, then it doesn't start from first again How i can fix it ? if backroundScreens == true then local BGimages = guiCreateStaticImage ( 0, 0, 1920, 1200, "img/BG1.jpg", true ) setTimer ( guiStaticImageLoadImage, 5000, 1, BGimages, "img/BG2.jpg" ) --guiCreateStaticImage( 0, 0, 1920, 1200, "img/BG1.jpg", false ) end
iPrestege Posted April 28, 2013 Posted April 28, 2013 You mean you want to images change every 10 sec like this 1 then 2 if 2 then 1 if 1 then 2 ?
FuriouZ Posted April 28, 2013 Author Posted April 28, 2013 No.Like this: Total i have 4 images. First image is "BG1" then after 5sec it changes to "BG2" then "BG3" then "BG4" and then all images are showed it starts from first again like BG1 BG2... Problem is that last image stops and staying there,but i need that if all 4 images are showed then starts again from first image
iPrestege Posted April 28, 2013 Posted April 28, 2013 Not tested but should work : Images = {"BG1.jpg","BG2.jpg","BG3.jpg","BG4.jpg"} local BGimages = guiCreateStaticImage ( 0, 0, 1920, 1200, "img/BG1.jpg", true ) local Time = 5000 local Tick = 0 local img = 0 addEventHandler( "onClientRender", root, function() local GetTick = getTickCount() if GetTick - Tick > Time then if img >= #Images then img = 0 end img = img + 1 local Data = Images[ ( img ) ] guiStaticImageLoadImage(BGimages,Data) Tick = GetTick end end ) ...
Castillo Posted April 28, 2013 Posted April 28, 2013 local images = { "BG1.jpg", "BG2.jpg", "BG3.jpg", "BG4.jpg" } local Time = 5000 local lastTick = getTickCount ( ) local img = 1 local BGimage = guiCreateStaticImage ( 0, 0, 1920, 1200, "img/BG1.jpg", true ) addEventHandler ( "onClientRender", root, function ( ) local curTick = getTickCount ( ) if ( curTick - lastTick > Time ) then img = ( img >= #images and 1 or img + 1 ) guiStaticImageLoadImage ( BGimage, images [ img ] ) lastTick = curTick end end ) Try it.
FuriouZ Posted April 28, 2013 Author Posted April 28, 2013 Thank you so much Solidsnake14 ! I got it working now Thanks to Mr.Pres[T]ege too also.
iPrestege Posted April 28, 2013 Posted April 28, 2013 local images = { "BG1.jpg", "BG2.jpg", "BG3.jpg", "BG4.jpg" } local Time = 5000 local lastTick = getTickCount ( ) local img = 1 local BGimage = guiCreateStaticImage ( 0, 0, 1920, 1200, "img/BG1.jpg", true ) addEventHandler ( "onClientRender", root, function ( ) local curTick = getTickCount ( ) if ( curTick - lastTick > Time ) then img = ( img >= #images and 1 or img + 1 ) guiStaticImageLoadImage ( BGimage, images [ img ] ) lastTick = curTick end end ) Try it. I am surprised that why my code does not work?Is this because relative position ?
Castillo Posted April 28, 2013 Posted April 28, 2013 No, I didn't change anything related to positions.
iPrestege Posted April 28, 2013 Posted April 28, 2013 No, I didn't change anything related to positions. OK,Thank you for fix the code .
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