Jump to content

What im Doing Wrong?


SnoopCat

Recommended Posts

i want to change vehiclecolors degraded randmly , i make this script (well not all by myself) for water color and works fine.... but when i chane it to setVehicleColor it doesnt works

can someone helps?

red     = math.random(0, 255) 
green   = math.random(0, 255) 
blue    = math.random(0, 255) 
aRed   = (1 + math.random(0, 1000)/1000) * 1.3 
aGreen = (1 + math.random(0, 1000)/1000) * 1.3 
aBlue  = (1 + math.random(0, 1000)/1000) * 1.3 
function changeColor() 
    if ((red + aRed) < 0) or ((red + aRed) > 255) then 
        aRed = aRed * -1 
    end 
    red = red + aRed 
    if ((green + aGreen) < 0) or ((green + aGreen) > 255) then 
        aGreen = aGreen * -1 
    end 
    green = green + aGreen 
    if ((blue + aBlue) < 0) or ((blue + aBlue) > 255) then 
        aBlue = aBlue * -1 
    end 
    blue = blue + aBlue 
    setVehicleColor(red, green, blue) 
end 
addEventHandler ( "onClientPreRender", root, changeColor ) 

PD:it only changes vehicle color randomly but not whit degraded

Link to comment
  
red     = math.random(0, 255) 
green   = math.random(0, 255) 
blue    = math.random(0, 255) 
aRed   = (1 + math.random(0, 1000)/1000) * 1.3 
aGreen = (1 + math.random(0, 1000)/1000) * 1.3 
aBlue  = (1 + math.random(0, 1000)/1000) * 1.3 
  
function changeColor()     
    for i, v in ipairs(getElementsByType("vehicle")) do 
        if ((red + aRed) < 0) or ((red + aRed) > 255) then 
            aRed = aRed * -1 
        end 
        red = red + aRed 
        if ((green + aGreen) < 0) or ((green + aGreen) > 255) then 
            aGreen = aGreen * -1 
        end 
        green = green + aGreen 
        if ((blue + aBlue) < 0) or ((blue + aBlue) > 255) then 
            aBlue = aBlue * -1 
        end 
        blue = blue + aBlue 
         
        setVehicleColor(v, red, green, blue) 
         
    end 
end 
addEventHandler ( "onClientPreRender", root, changeColor ) 
  

Link to comment

-- server side:

function randomVehicleColors() 
    for index, vehicle in ipairs(getElementsByType("vehicle")) do 
        red = math.random(0,255) 
        green = math.random(0,255) 
        blue = math.random(0,255) 
        setVehicleColor (vehicle, red, green, blue) 
    end 
end  
setTimer( randomVehicleColors, 1000, 0 ) 

Link to comment

Shader applied to 'waterclear256'

Shader:

float Time : TIME ; 
  
float4 GetColor ( ) 
{ 
    return float4 ( cos ( Time ) , cos ( Time ) , cos ( Time ) , 1 ) ; 
} 
  
technique tec0 
{ 
    pass P0 
    { 
        MaterialAmbient = GetColor ( ) ; 
        MaterialDiffuse = GetColor ( ) ; 
        MaterialEmissive = GetColor ( ) ; 
        MaterialSpecular = GetColor ( ) ; 
         
        AmbientMaterialSource = Material ; 
        DiffuseMaterialSource = Material ; 
        EmissiveMaterialSource = Material ; 
        SpecularMaterialSource = Material ; 
         
        Lighting = true ; 
    } 
} 

Client:

addEventHandler( "onClientResourceStart", resourceRoot, 
    function() 
        local myShader, tec = dxCreateShader ( "shader.fx" ) 
        if myShader then 
            engineApplyShaderToWorldTexture ( myShader, "waterclear256" ) 
        end 
    end 
) 
  

Not tested.

Link to comment
Shader applied to 'waterclear256'

Shader:

float Time : TIME ; 
  
float4 GetColor ( ) 
{ 
    return float4 ( cos ( Time ) , cos ( Time ) , cos ( Time ) , 1 ) ; 
} 
  
technique tec0 
{ 
    pass P0 
    { 
        MaterialAmbient = GetColor ( ) ; 
        MaterialDiffuse = GetColor ( ) ; 
        MaterialEmissive = GetColor ( ) ; 
        MaterialSpecular = GetColor ( ) ; 
         
        AmbientMaterialSource = Material ; 
        DiffuseMaterialSource = Material ; 
        EmissiveMaterialSource = Material ; 
        SpecularMaterialSource = Material ; 
         
        Lighting = true ; 
    } 
} 

Client:

addEventHandler( "onClientResourceStart", resourceRoot, 
    function() 
        local myShader, tec = dxCreateShader ( "shader.fx" ) 
        if myShader then 
            engineApplyShaderToWorldTexture ( myShader, "waterclear256" ) 
        end 
    end 
) 
  

Not tested.

why u posted this? its for blending colors of Cars?

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