SnoopCat Posted October 6, 2011 Posted October 6, 2011 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
Cadu12 Posted October 6, 2011 Posted October 6, 2011 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 )
Cadu12 Posted October 6, 2011 Posted October 6, 2011 I have tested and works, are you using server-side? if so, change to client-side
Cadu12 Posted October 6, 2011 Posted October 6, 2011 uh? what do you mean? if you want change car color?
SnoopCat Posted October 6, 2011 Author Posted October 6, 2011 i mean this... this is an example whit the same script i gived but whit setWaterColor.
Castillo Posted October 6, 2011 Posted October 6, 2011 -- 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 )
SnoopCat Posted October 6, 2011 Author Posted October 6, 2011 it changes but not like showed on video...
Castillo Posted October 6, 2011 Posted October 6, 2011 Do you mean the speed of changing? if so, change the timer that it's set to 1 second to less.
JR10 Posted October 6, 2011 Posted October 6, 2011 You mean blending? There is no function for that, but I think the script in the video is using shaders.
SnoopCat Posted October 6, 2011 Author Posted October 6, 2011 blending its possibly on cars.... i see it on server FFS racing.. and the script on the video is the same as the first one i posted but whit setWaterColor
JR10 Posted October 6, 2011 Posted October 6, 2011 I didn't say it's impossible. You will need getWaterColor, then - 1 and setWaterColor to the new values. And check if it's 0, and then math.random to get new values, and so on.
SnoopCat Posted October 6, 2011 Author Posted October 6, 2011 but why the code i posted doent works if it works whit setWaterColor
JR10 Posted October 6, 2011 Posted October 6, 2011 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.
SnoopCat Posted October 6, 2011 Author Posted October 6, 2011 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?
SnoopCat Posted October 6, 2011 Author Posted October 6, 2011 works whit water... and it changes white to black color but car doesnt works and i want car only whit random rgb colors..
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now