killingyasoon Posted September 29, 2018 Share Posted September 29, 2018 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. Link to comment
NeXuS™ Posted September 29, 2018 Share Posted September 29, 2018 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) 1 Link to comment
JeViCo Posted September 29, 2018 Share Posted September 29, 2018 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 1 Link to comment
killingyasoon Posted September 29, 2018 Author Share Posted September 29, 2018 (edited) actually, it works, but it's some sort of glitchy and causes some fps drops. @JeViCo i am using it on a login panel by the way, when i login, it still keeps running @Nexus Edited September 29, 2018 by killingyasoon Link to comment
JeViCo Posted September 29, 2018 Share Posted September 29, 2018 @killingyasoon walls = {"wall_1.png","wall_2.png","wall_3.png"} -- your wallpapers num = 1 setTimer(function() num = num + 1 if num > #walls then num = 1 end end,3*1000,0) -- 3 seconds addEventHandler("onClientRender",root,function() -- drawing image stuff dxDrawImage(0,0,100,100,walls[num]) end) fixed 1 Link to comment
NeXuS™ Posted September 29, 2018 Share Posted September 29, 2018 @killingyasoon You'll have to add an event to remove the eventhandler when the player logins. 1 Link to comment
killingyasoon Posted September 29, 2018 Author Share Posted September 29, 2018 thank you both, works totally fine. 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