SnoopCat Posted September 30, 2011 Share Posted September 30, 2011 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
karlis Posted September 30, 2011 Share Posted September 30, 2011 u have to specify only 3args in vehicle colors, if u want 1st color rgb, plus syntax error at line 38 Link to comment
Cadu12 Posted September 30, 2011 Share Posted September 30, 2011 and 14 lines. change it to "onClientResourceStart" Link to comment
zorrigas Posted September 30, 2011 Share Posted September 30, 2011 onResourceStart is ServerSide event, cant runit on ClientSide, Bad Copy Paste. setVehicleColor(VEHICLE NO ID, color1,color2,color3,color4) Link to comment
SnoopCat Posted September 30, 2011 Author Share Posted September 30, 2011 (edited) 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 September 30, 2011 by Guest Link to comment
Cadu12 Posted September 30, 2011 Share Posted September 30, 2011 (edited) Are you using Server-side? If so, change to client-side. resetWaterColor and setWaterColor is only for client-side Edit: Or you can use trigger https://wiki.multitheftauto.com/wiki/TriggerClientEvent Edited September 30, 2011 by Guest Link to comment
zorrigas Posted September 30, 2011 Share Posted September 30, 2011 (edited) 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 September 30, 2011 by Guest Link to comment
SnoopCat Posted September 30, 2011 Author Share Posted September 30, 2011 i have to use server side or client side to make this script???? im confused Link to comment
karlis Posted September 30, 2011 Share Posted September 30, 2011 try specifying all 12 color arguments(rgb for 4colors) use serverside if want it synced, clientside, if want unsynced Link to comment
SnoopCat Posted September 30, 2011 Author Share Posted September 30, 2011 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 Link to comment
karlis Posted September 30, 2011 Share Posted September 30, 2011 1)im not sure how mta detects, is it rgb, or color id, kinda think problem is there.try AT LEAST 2sets of rgb. 2)root is defined? 3)getElementsByType 4times a second is very expensive, don't call it that often. Link to comment
SnoopCat Posted September 30, 2011 Author Share Posted September 30, 2011 what u mean whit point 2 and 3? Link to comment
zorrigas Posted September 30, 2011 Share Posted September 30, 2011 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
TAPL Posted September 30, 2011 Share Posted September 30, 2011 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
zorrigas Posted September 30, 2011 Share Posted September 30, 2011 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 viewtopic.php?f=91&t=36202&p=373313#p373310 Link to comment
SnoopCat Posted September 30, 2011 Author Share Posted September 30, 2011 the one posted zorrigas is working but it is not like degrading Link to comment
TAPL Posted September 30, 2011 Share Posted September 30, 2011 lol but this will make Vehicles and water and sky same color .... Link to comment
SnoopCat Posted September 30, 2011 Author Share Posted September 30, 2011 yup but how i make it change colors by degrade? Link to comment
zorrigas Posted September 30, 2011 Share Posted September 30, 2011 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
SnoopCat Posted September 30, 2011 Author Share Posted September 30, 2011 but doesnt changes degraded 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