Jump to content

Backround timer?


FuriouZ

Recommended Posts

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 

Link to comment

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

Link to comment

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 
) 

...

Link to comment
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.

Link to comment
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 ?

Link to comment

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