Jump to content

How can i make Automatic playing wallpapers


killingyasoon

Recommended Posts

  • Scripting Moderators
local wallpaperDirectory = "wallpapers/"
local selectedWallpaper = 1

local wallpapersTable = {
	"moutain",
	"horse",
	"car",
	"river"
}

function drawWallpapers()
	dxDrawImage(0, 0, 512, 512, wallpaperDirectory .. wallpapersTable[selectedWallpaper] .. ".png")
end
addEventHandler("onClientRender", root, drawWallpapers)

setTimer(function()
	selectedWallpaper = wallpapersTable[selectedWallpaper+1] and selectedWallpaper+1 or 1
end, 5000, 0)

 

  • Like 1
Link to comment
22 minutes ago, killingyasoon said:

as you can see on the title, How can i make Automatic playing wallpapers, i got 4 wallpapers and i want to play them all but 1 by 1, they get changed every 5 secs or so.

any type of help will be appreciated.

walls = {"wall_1.png","wall_2.png"} -- your wallpapers
num = 1

setTimer(function()
	num = num + 1
	if num > #walls then
		num = 1
	end
end,3*1000,1) -- 3 seconds
    
addEventHandler("onClientRender",root,function()
	-- drawing image stuff
	dxDrawImage(0,0,100,100,walls[num]
end)

you can also add smooth transitions using interpolateBetween + render targets

  • Like 1
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...