Jump to content

What im Doing Wrong?


SnoopCat

Recommended Posts

Posted

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

VISIT TSW RACING SERVER

http://tswracing.net/

Posted
  
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 ) 
  

Ingame nick: Cadu12

Posted

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

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Do you mean the speed of changing? if so, change the timer that it's set to 1 second to less.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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.

Business System viewtopic.php?f=108&t=35797

Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726

SQLite Tutorial viewtopic.php?f=148&t=38203

Posted
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?

VISIT TSW RACING SERVER

http://tswracing.net/

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