GrubaS Posted May 29, 2015 Posted May 29, 2015 Hello guys, it's possible to make rainbow colors for one car? not for all? (every 5 secounds change colors) function randomVehColors() for i, car in ipairs( getElementsByType( "vehicle" ) ) do local color = {} color[1] = math.random(0,126) color[2] = math.random(0,126) color[3] = math.random(0,126) color[4] = math.random(0,126) setVehicleColor ( car, color[1], color[2], color[3], color[4] ) end end setTimer( randomVehColors, 500, 0 )
Walid Posted May 29, 2015 Posted May 29, 2015 it's not 5 seconds 500 = 0.5 seconds 5000 = 5 seconds Anyways yes you can.
-Doc- Posted May 29, 2015 Posted May 29, 2015 function evil() for i, car in ipairs(getElementsByType("")) do red = math.random(0, 255) green = math.random(0, 255) blue = math.random(0, 255) setVehicleHeadLightColor(car, red, green, blue) end end function muh () for k, v in ipairs(getElementsByType("vehicle")) do local x, y, z = getElementPosition(v) local c = math.random(0, 126) setVehicleColor(v, c, c, c, c) fxAddGlass(x, y, z, math.random(0, 255), math.random(0, 255), math.random(0, 255), math.random(0, 255), 0.08, 1) end end function effects () if effectson == 1 then effectsnein () elseif effectson == 2 then effectsja () end end function effectsja () addEventHandler("onClientRender", getRootElement(), evil) addEventHandler("onClientRender", getRootElement(), muh) addEventHandler( "onClientResourceStart", getResourceRootElement(getThisResource()), defineTheRGB ) effectson = 1 timer = setTimer(defineTheRGB(),500-difference,1) end function effectsnein () removeEventHandler("onClientRender", getRootElement(), evil) removeEventHandler("onClientRender", getRootElement(), muh) removeEventHandler( "onClientResourceStart", getResourceRootElement(getThisResource()), defineTheRGB ) resetSkyGradient() killTimer(timera) difference = getTickCount()-start effectson = 2 end
GrubaS Posted May 29, 2015 Author Posted May 29, 2015 I want make it (rainbowcolor) in gui but when i press button "Disco Car" its working for all Client Side! GUIEditor = { button = {}, window = {} } spawnScreenMenu = guiCreateWindow(146, 253, 359, 149, "", false) guiWindowSetSizable(spawnScreenMenu, false) guiSetAlpha(spawnScreenMenu, 0.46) guiSetVisible(spawnScreenMenu, false) guiWindowSetSizable(spawnScreenMenu, false) przycisk = guiCreateButton(10, 56, 124, 46, "Disco Car", false, spawnScreenMenu) guiSetFont(przycisk, "default-bold-small") guiSetProperty(przycisk, "NormalTextColour", "FF2BDF01") przycisk2 = guiCreateButton(225, 56, 124, 46, "Disco Lights", false, spawnScreenMenu) guiSetFont(przycisk2, "default-bold-small") guiSetProperty(przycisk2, "NormalTextColour", "FF2BDF01") addCommandHandler("gowno", function () guiSetVisible ( spawnScreenMenu, not guiGetVisible ( spawnScreenMenu ) ) showCursor ( guiGetVisible ( spawnScreenMenu ) ) end) function rainbowColor() triggerServerEvent ( "gowno1", resourceRoot ) end function discoheadlights() triggerServerEvent ( "gowno2", resourceRoot ) end isRainbowColor = false isLightRainbowColor = false addEventHandler("onClientGUIClick", root, function() if ( source == przycisk ) then if isRainbowColor then if isTimer(RainbowTimer) then killTimer(RainbowTimer) end isRanbowColor = false else RainbowTimer = setTimer(rainbowColor,500,0) isRanbowColor = true end elseif ( source == przycisk2 ) then if isLightRainbowColor then if isTimer(LightTimer) then killTimer(LightTimer) end isLightRainbowColor = false else LightTimer = setTimer(discoheadlights,500,0) isLightRainbowColor = true end end end ) Server Side! addEvent( "gowno1", true ) addEventHandler( "gowno1", resourceRoot, function () for id,player in ipairs(getElementsByType("player")) do local vehicle = getPedOccupiedVehicle(player) if vehicle then if getElementDimension(vehicle) == 0 then setVehicleColor(vehicle, 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 end end addEvent( "gowno2", true ) addEventHandler( "gowno2", resourceRoot, function (btn) for id,player in ipairs(getElementsByType("player")) do local car = getPedOccupiedVehicle(player) if car and isElement(car) then local l1 = getVehicleLightState(car,0) if l1 == 0 then setVehicleHeadLightColor(car,math.random(0,255),math.random(0,255),math.random(0,255)) setVehicleLightState(car,0,1) setVehicleLightState(car,2,1) setVehicleLightState(car,1,0) setVehicleLightState(car,3,0) else setVehicleHeadLightColor(car,math.random(0,255),math.random(0,255),math.random(0,255)) setVehicleLightState(car,0,0) setVehicleLightState(car,2,0) setVehicleLightState(car,1,1) setVehicleLightState(car,3,1) end end end end
SpecT Posted May 31, 2015 Posted May 31, 2015 You used "for id,player in ipairs(getElementsByType("player")) do" which means it will set the car color/lights to everyone. When you trigger the event from client-side put localPlayer, and add it in the server side. So it will change just the client's car color/lights but not everyone's.
iMr.Dawix~# Posted May 31, 2015 Posted May 31, 2015 Client Side GUIEditor = { button = {}, window = {} } spawnScreenMenu = guiCreateWindow(146, 253, 359, 149, "", false) guiWindowSetSizable(spawnScreenMenu, false) guiSetAlpha(spawnScreenMenu, 0.46) guiSetVisible(spawnScreenMenu, false) guiWindowSetSizable(spawnScreenMenu, false) przycisk = guiCreateButton(10, 56, 124, 46, "Disco Car", false, spawnScreenMenu) guiSetFont(przycisk, "default-bold-small") guiSetProperty(przycisk, "NormalTextColour", "FF2BDF01") przycisk2 = guiCreateButton(225, 56, 124, 46, "Disco Lights", false, spawnScreenMenu) guiSetFont(przycisk2, "default-bold-small") guiSetProperty(przycisk2, "NormalTextColour", "FF2BDF01") addCommandHandler("gowno", function () guiSetVisible ( spawnScreenMenu, not guiGetVisible ( spawnScreenMenu ) ) showCursor ( guiGetVisible ( spawnScreenMenu ) ) end ) function rainbowColor() triggerServerEvent ( "gowno1", localPlayer) end function discoheadlights() triggerServerEvent ( "gowno2", localPlayer) end isRainbowColor = false isLightRainbowColor = false addEventHandler("onClientGUIClick", root, function() if ( source == przycisk ) then if isRainbowColor then if isTimer(RainbowTimer) then killTimer(RainbowTimer) end isRanbowColor = false else RainbowTimer = setTimer(rainbowColor,500,0) isRanbowColor = true end elseif ( source == przycisk2 ) then if isLightRainbowColor then if isTimer(LightTimer) then killTimer(LightTimer) end isLightRainbowColor = false else LightTimer = setTimer(discoheadlights,500,0) isLightRainbowColor = true end end end ) -- Server Side addEvent( "gowno1", true ) addEventHandler( "gowno1", root, function () local vehicle = getPedOccupiedVehicle(source) if vehicle then if getElementDimension(vehicle) == 0 then setVehicleColor(vehicle, math.random(255), math.random(255), math.random(255), math.random(255), math.random(255), math.random(255)) end end end addEvent( "gowno2", true ) addEventHandler( "gowno2", root, function (btn) local car = getPedOccupiedVehicle(source) if car and isElement(car) then local l1 = getVehicleLightState(car,0) if l1 == 0 then setVehicleHeadLightColor(car,math.random(255),math.random(255),math.random(255)) setVehicleLightState(car,0,1) setVehicleLightState(car,2,1) setVehicleLightState(car,1,0) setVehicleLightState(car,3,0) else setVehicleHeadLightColor(car,math.random(255),math.random(255),math.random(255)) setVehicleLightState(car,0,0) setVehicleLightState(car,2,0) setVehicleLightState(car,1,1) setVehicleLightState(car,3,1) end end end
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