Jump to content

Backround timer?


FuriouZ

Recommended Posts

Posted

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 :roll:

Anyway one shot is here :

mta-screen_2013-04-28_20-20-52.png

Posted
setTimer or "onClientRender" 
guiStaticImageLoadImage 

Use these functions .

Thanks,but if images images end, then it doesn't start from first again :roll:

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 

Posted

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 :|

Posted

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 
) 

...

Posted
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.

Posted
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 ?

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...