Jump to content

Sky GRadient Water color and vehicle color problem


SnoopCat

Recommended Posts

hi mi problem is i want to do sky color, car color and water color change randmly but degraded. and its not doing nothing...

can someone says me what im doing wrong or just help me?

        addEventHandler("onClientResourceStop", getRootElement(), 
            function() 
               resetWaterColor() 
               resetSkyGradient() 
               resetVehicleColor() 
            end) 
      
    addEventHandler("onClientResourceStart", getRootElement(), 
           function water() 
setWaterColor(math.random (0,255), math.random (0,255), math.random (0,255)) 
end 
setTimer ( water, 275, 0 ) 
  
addEventHandler ( "onResourceStart", root, water ) 
  
      
    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 ) 
        ) 
            end) 
  
setTimer(setSkyGradient, 275, 0 ) 
      
  
function randomVehColors() 
    for i, car in ipairs( getElementsByType( "vehicle" ) ) do 
        local color = {} 
        color[1] = math.random(0,255)  
        color[2] = math.random(0,255) 
        color[3] = math.random(0,255) 
        color[4] = math.random(0,255) colors 
        setVehicleColor ( 411, color[1], color[2], color[3], color[4] )  
    end 
end 
  
setTimer( randomVehColors, 275, 0 )  

Link to comment

this is what i do now and is nto working

i place dit server side and i do this:

    addEventHandler("onClientResourceStart", getRootElement(), 
            function() 
               resetWaterColor() 
               resetSkyGradient() 
               resetVehicleColor() 
            end) 
      
    addEventHandler("onClientResourceStart", getRootElement(), 
           function water() 
setWaterColor(math.random (0,255), math.random (0,255), math.random (0,255)) 
end 
setTimer ( water, 275, 0 ) 
  
addEventHandler ( "onClientResourceStart", root, water ) 
  
      
    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 ) 
        ) 
            end) 
  
setTimer(setSkyGradient, 275, 0 ) 
      
  
function randomVehColors() 
    for i, car in ipairs( getElementsByType( "vehicle" ) ) do 
        local color = {} 
        color[1] = math.random(0,255) 
        color[2] = math.random(0,255) 
        color[3] = math.random(0,255) 
        setVehicleColor ( infernus, color[1], color[2], color[3] ) 
    end 
end 
  
setTimer( randomVehColors, 275, 0 )  

Edited by Guest
Link to comment
resetWaterColor and setWaterColor is only for client-side

you are bad. resetWaterColor and setWaterColor is Client and Server function on 1.1!

all functions work in serverside but have a bad elements.

  
for i, car in ipairs( getElementsByType( "vehicle" ) ) do 
        ....... 
        setVehicleColor ( car, color[1], color[2], color[3] ) 
    end 
end 
  

PD for SnoopCat: Fuga ahora no puedes decir que no te ayude, deja de hacer copy paste de scripts y lee el wiki!

Edited by Guest
Link to comment

soo i have made this for server side.... its ok?

  
  addEventHandler("onResourceStart", getRootElement(), 
  
           function water() 
setWaterColor(math.random (0,255), math.random (0,255), math.random (0,255)) 
end 
setTimer ( water, 275, 0 ) 
addEventHandler ( "onResourceStart", root, water ) 
  
      
    addEventHandler("onResourceStart", 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 ) 
        ) 
            end) 
  
setTimer(setSkyGradient, 275, 0 ) 
      
  
function randomVehColors() 
    for i, car in ipairs( getElementsByType( "vehicle" ) ) do 
        local color = {} 
        color[1] = math.random(0,255) 
        color[2] = math.random(0,255) 
        color[3] = math.random(0,255) 
        setVehicleColor ( car, color[1], color[2], color[3] ) 
    end 
end 
  
setTimer( randomVehColors, 275, 0 )  

pd its not working on the sv :S

Link to comment

Working Script, ServerSide, not tested but should work [1.1]

  
-- zorrigas 18:21 GMT-4 30/SEPT/2011 
resRoot = getResourceRootElement(getThisResource()) 
addEventHandler("onResourceStop", resRoot, 
            function() 
               resetWaterColor() 
               resetSkyGradient() 
               resetVehicleColor() 
            end) 
      
addEventHandler("onResourceStart", resRoot, 
        function() 
        setTimer(colores,275,0) 
        end) 
         
function colores() 
    -- se definen los colores 
    local color1 = math.random(0,255) 
    local color2 = math.random(0,255) 
    local color3 = math.random(0,255) 
    local color4 = math.random(0,255) 
    local color5 = math.random(0,255) 
    local color6 = math.random(0,255) 
     
    setSkyGradient(color1,color2,color3,color4,color5,color6) 
    setWaterColor(color1,color2,color3) 
    for i, auto in ipairs( getElementsByType( "vehicle" ) ) do 
        setVehicleColor ( auto,color1,color2,color3,color4,color5,color6 ) 
    end 
end 
  

Link to comment
function water() 
setWaterColor(math.random (0,255), math.random (0,255), math.random (0,255)) 
end 
setTimer ( water, 275, 0 ) 
  
function setSkyGradient() 
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 )) 
end 
setTimer(setSkyGradient, 275, 0 ) 
  
function randomVehColors() 
    for i, car in ipairs( getElementsByType( "vehicle" ) ) do 
        local color = {} 
        color[1] = math.random(0,255) 
        color[2] = math.random(0,255) 
        color[3] = math.random(0,255) 
        setVehicleColor ( car, color[1], color[2], color[3] ) 
    end 
end 
setTimer( randomVehColors, 275, 0 ) 

Link to comment
function water() 
setWaterColor(math.random (0,255), math.random (0,255), math.random (0,255)) 
end 
setTimer ( water, 275, 0 ) 
  
function setSkyGradient() 
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 )) 
end 
setTimer(setSkyGradient, 275, 0 ) 
  
function randomVehColors() 
    for i, car in ipairs( getElementsByType( "vehicle" ) ) do 
        local color = {} 
        color[1] = math.random(0,255) 
        color[2] = math.random(0,255) 
        color[3] = math.random(0,255) 
        setVehicleColor ( car, color[1], color[2], color[3] ) 
    end 
end 
setTimer( randomVehColors, 275, 0 ) 

to many timers, all functions on 1 timer :Dviewtopic.php?f=91&t=36202&p=373313#p373310

Link to comment

All Random

  
-- zorrigas 18:32 GMT-4 30/SEPT/2011 
resRoot = getResourceRootElement(getThisResource()) 
addEventHandler("onResourceStop", resRoot, 
            function() 
               resetWaterColor() 
               resetSkyGradient() 
               resetVehicleColor() 
            end) 
      
addEventHandler("onResourceStart", resRoot, 
        function() 
        setTimer(colores,275,0) 
        end) 
        
function colores() 
    -- se definen los colores 
    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)) 
    for i, auto in ipairs( getElementsByType( "vehicle" ) ) do 
        setVehicleColor ( auto,math.random(0,255),math.random(0,255),math.random(0,255),math.random(0,255),math.random(0,255),math.random(0,255) ) 
    end 
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...