Jump to content

Random Colors


SnoopCat

Recommended Posts

hey i have a skygradient and water color script but i want to make it changes to a random color every 5 mins how i can do this???? here is the cod ei have:

addEventHandler("onClientResourceStop", getRootElement(),  
        function() 
           resetWaterColor() 
        end) 
  
addEventHandler("onClientResourceStart", getRootElement(),  
        function() 
           setWaterColor(4, 140, 251) 
        end) 
  
addEventHandler("onClientResourceStart", getRootElement(),  
        function() 
           setSkyGradient(255, 128, 0 , 0 , 0 , 0) 
        end) 
  

Link to comment

1. You need to get random values and put em into setSkyGradient() and setWaterColor()

2. You need a timer to cycle it every 5 minutes ( 300000 milliseconds)

So what comes straight on my mind is: (didn't test)

setTimer( 
    function() 
        setSkyGradient( 
            math.random( 0, 255 ), 
            math.random( 0, 255 ), 
            math.random( 0, 255 ), 
            math.random( 0, 255 ), 
            math.random( 0, 255 ), 
            math.random( 0, 255 ) 
        ) 
        setWaterColor( 
            math.random( 0, 255 ), 
            math.random( 0, 255 ), 
            math.random( 0, 255 ) 
        ) 
    end 
, 300000, 0 ) 

Link to comment

Use:

  
addEventHandler("onClientResourceStop", getRootElement(),function() 
    resetSkyGradient() 
    resetWaterColor() 
end) 
addEventHandler("onClientResourceStart",getRootElement(),function() 
    setSkyGradient(math.random(0,255),math.random(0,255),math.random(0,255),math.random(0,255),math.random(0,255),math.random(0,255)) 
    setWaterColor(math.random(0,255),math.random(0,255),math.random(0,255)) 
    setTimer(function() 
        setSkyGradient(math.random(0,255),math.random(0,255),math.random(0,255),math.random(0,255),math.random(0,255),math.random(0,255)) 
        setWaterColor(math.random(0,255),math.random(0,255),math.random(0,255)) 
    end,300000,0) 
end) 
  

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