SnoopCat Posted October 6, 2011 Share 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 Link to comment
Cadu12 Posted October 6, 2011 Share 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 ) Link to comment
Cadu12 Posted October 6, 2011 Share Posted October 6, 2011 I have tested and works, are you using server-side? if so, change to client-side Link to comment
SnoopCat Posted October 6, 2011 Author Share Posted October 6, 2011 its change colors but not degraded Link to comment
Cadu12 Posted October 6, 2011 Share Posted October 6, 2011 uh? what do you mean? if you want change car color? Link to comment
SnoopCat Posted October 6, 2011 Author Share Posted October 6, 2011 i mean this... this is an example whit the same script i gived but whit setWaterColor. Link to comment
Castillo Posted October 6, 2011 Share 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 ) Link to comment
SnoopCat Posted October 6, 2011 Author Share Posted October 6, 2011 it changes but not like showed on video... Link to comment
Castillo Posted October 6, 2011 Share 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. Link to comment
JR10 Posted October 6, 2011 Share Posted October 6, 2011 You mean blending? There is no function for that, but I think the script in the video is using shaders. Link to comment
SnoopCat Posted October 6, 2011 Author Share 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 Link to comment
JR10 Posted October 6, 2011 Share 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. Link to comment
SnoopCat Posted October 6, 2011 Author Share Posted October 6, 2011 but why the code i posted doent works if it works whit setWaterColor Link to comment
SnoopCat Posted October 6, 2011 Author Share Posted October 6, 2011 shader water is diferent as the script Link to comment
JR10 Posted October 6, 2011 Share 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. Link to comment
SnoopCat Posted October 6, 2011 Author Share 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? Link to comment
SnoopCat Posted October 6, 2011 Author Share 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.. Link to comment
SnoopCat Posted October 8, 2011 Author Share Posted October 8, 2011 any other help plz? Link to comment
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