Results 1 to 2 of 2
  1. #1
    Bloom_'s Avatar
    Join Date
    Aug 2017
    Gender
    female
    Posts
    1
    Reputation
    10
    Thanks
    3

    Question DFrame Custom Background Material

    How do you make this code change the background of a DFrame slower, because when i put this in the paint function it just changes superfast.

    Code:
    local Backgrounds = { "image1", "image2", "image3", "image4", "image5", "image6" }
    
    surface.SetDrawColor( 255, 255, 255, 255 )
    		
    surface.SetMaterial( Material( table.Random( Backgrounds ) .. ".jpg" ) )
    		
    surface.DrawTexturedRect( 0, 0, DermaFrame:GetWide(), DermaFrame:GetTall() )
    Last edited by Bloom_; 08-30-2017 at 02:01 AM.

  2. #2
    Cyaegha's Avatar
    Join Date
    Aug 2016
    Gender
    male
    Posts
    536
    Reputation
    17
    Thanks
    526
    Code:
    local Backgrounds = {
    	"gui/center_gradient",
    	"gui/gradient",
    	"gui/gradient_down",
    	"gui/gradient_up",
    }
    local delay = 2 -- how long it takes for the background to change in seconds
    
    -- ALWAYS cache materials outside of any hooks
    for i, img in next, Backgrounds do -- loop through Backgrounds
    	Backgrounds[i] = Material(img) -- replace the string with the material
    end
    
    hook.Add("HUDPaint", "material shit", function()
    	local bgnd = #Backgrounds * delay
    	local i = CurTime() % bgnd -- this will return a float between 0 and bgnd
    	i = math.Remap(i, 0, bgnd, 0, #Backgrounds)
    	i = math.floor(i) + 1 -- table indexes start at 1, not 0.
    
    	surface.SetDrawColor(color_black)
    	surface.SetMaterial(Backgrounds[i]) -- set the material
    	surface.DrawTexturedRect(0, 0, ScrW(), ScrH()) -- instead of using ScrW and ScrH use the width and height passed to Panel:Paint instead of calling 2 functions
    end)

Similar Threads

  1. [Help Request] custom background for mw3
    By raminr1363 in forum Call of Duty Modern Warfare 3 Help
    Replies: 0
    Last Post: 01-16-2012, 03:01 PM
  2. MW2 custom background request!
    By rovald in forum Call of Duty Modern Warfare 2 Texture Requests
    Replies: 1
    Last Post: 07-07-2011, 02:17 AM
  3. [Tutorial] Custom Background Music in 10 Easy steps
    By ZeroTroubles in forum Call of Duty Modern Warfare 2 Tutorials
    Replies: 50
    Last Post: 08-29-2010, 07:54 AM
  4. Get your Mw2 Custom Background Music here
    By Archangel in forum Call of Duty Modern Warfare 2 Discussions
    Replies: 107
    Last Post: 08-02-2010, 05:24 AM
  5. Custom Background Music
    By Jackal in forum WarRock - International Hacks
    Replies: 6
    Last Post: 08-09-2006, 07:12 PM