xR|TURBO Posted May 11, 2013 Posted May 11, 2013 I MADE A PANEL. I CAN NOT UNDERSTAND THAT ONLY ONE ERROR. WHEN I ENTER IN THE SERVER THE FUNCTION PART WITHOUT I CLICK THE BOTTON. WHEN I CLICK THE BOTTON DO NOT REMOVE THE MONEY AND THE FUNCTION NOT PART guiCreateLabel(0.50, 0.10, 0.30, 0.09, "Prince:$500000", true, Tab[7]) disco = guiCreateButton (0.50, 0.15, 0.40, 0.09, "DISCO LIGHTS", true, Tab[7]) guiCreateLabel(0.50, 0.25, 0.30, 0.09, "Prince:$500000", true, Tab[7]) rainbowColor = guiCreateButton (0.50, 0.30, 0.40, 0.09, "DISCO CAR", true, Tab[7]) addEventHandler("onClientGUIClick",disco,discoheadlights,false) addEventHandler("onClientGUIClick",rainbowColor,rainbowColor,false) r,g,b = 255,255,255 upValues = true function rainbowColor (btn) if upValues == true then if g <= 255 and g >= 0 and r == 0 and b == 255 then r,g,b = r,g-6.375,b end if r <= 255 and r >= 0 and g == 255 and b == 255 then r,g,b = r-6.375,g,b end if b <= 255 and b >= 0 and r == 0 and g == 0 then r,g,b = r,g,b-6.375 end if r == 0 and g == 0 and b == 0 then upValues = false end end if upValues == false then if g <= 255 and g >= 0 and r == 255 and b == 0 then r,g,b = r,g+6.375,b end if r <= 255 and r >= 0 and g == 0 and b == 0 then r,g,b = r+6.375,g,b end if b <= 255 and b >= 0 and r == 255 and g == 255 then r,g,b = r,g,b+6.375 end if r == 255 and g == 255 and b == 255 then upValues = true end end for id,player in ipairs(getElementsByType("player")) do local vehicle = getPedOccupiedVehicle(player) if vehicle then if getElementDimension(vehicle) == 0 then setVehicleColor(vehicle,r,g,b,r,g,b) end end end end setTimer(rainbowColor,50,0) function discoheadlights (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 setTimer(discoheadlights,1000,0)
xR|TURBO Posted May 12, 2013 Author Posted May 12, 2013 There are no errors and only that instead of starting when I click on the start button. part when I enter in the server.
PaiN^ Posted May 12, 2013 Posted May 12, 2013 That's because you're seting a timer for the function . Timer should be with onClientGUIClick event .
xR|TURBO Posted May 12, 2013 Author Posted May 12, 2013 I do not understand you can show me the code with the function onClientGUIClick.
Sasu Posted May 12, 2013 Posted May 12, 2013 Try this: guiCreateLabel(0.50, 0.10, 0.30, 0.09, "Prince:$500000", true, Tab[7]) disco = guiCreateButton (0.50, 0.15, 0.40, 0.09, "DISCO LIGHTS", true, Tab[7]) guiCreateLabel(0.50, 0.25, 0.30, 0.09, "Prince:$500000", true, Tab[7]) rainbowColor = guiCreateButton (0.50, 0.30, 0.40, 0.09, "DISCO CAR", true, Tab[7]) r,g,b = 255,255,255 upValues = true function rainbowColor (btn) if upValues == true then if g <= 255 and g >= 0 and r == 0 and b == 255 then r,g,b = r,g-6.375,b end if r <= 255 and r >= 0 and g == 255 and b == 255 then r,g,b = r-6.375,g,b end if b <= 255 and b >= 0 and r == 0 and g == 0 then r,g,b = r,g,b-6.375 end if r == 0 and g == 0 and b == 0 then upValues = false end end if upValues == false then if g <= 255 and g >= 0 and r == 255 and b == 0 then r,g,b = r,g+6.375,b end if r <= 255 and r >= 0 and g == 0 and b == 0 then r,g,b = r+6.375,g,b end if b <= 255 and b >= 0 and r == 255 and g == 255 then r,g,b = r,g,b+6.375 end if r == 255 and g == 255 and b == 255 then upValues = true end end for id,player in ipairs(getElementsByType("player")) do local vehicle = getPedOccupiedVehicle(player) if vehicle then if getElementDimension(vehicle) == 0 then setVehicleColor(vehicle,r,g,b,r,g,b) end end end end function discoheadlights (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 isRainbowColor = false isLightRainbowColor = false addEventHandler("onClientGUIClick", root, function() if ( source == rainbowColor ) then if isRainbowColor then if isTimer(RainbowTimer) then killTimer(RainbowTimer) end isRanbowColor = false else RainbowTimer = setTimer(rainbowColor,50,0) isRanbowColor = true end elseif ( source == disco ) then if isLightRainbowColor then if isTimer(LightTimer) then killTimer(LightTimer) end isLightRainbowColor = false else LightTimer = setTimer(discoheadlights,1000,0) isLightRainbowColor = true end end end ) You can turn on and turn off.
Sasu Posted May 13, 2013 Posted May 13, 2013 function rainbowColor () 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 function discoheadlights (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 isRainbowColor = false isLightRainbowColor = false addEventHandler("onClientGUIClick", root, function() if ( source == rainbowColor ) then if isRainbowColor then if isTimer(RainbowTimer) then killTimer(RainbowTimer) end isRanbowColor = false else RainbowTimer = setTimer(rainbowColor,1000,0) isRanbowColor = true end elseif ( source == disco ) then if isLightRainbowColor then if isTimer(LightTimer) then killTimer(LightTimer) end isLightRainbowColor = false else LightTimer = setTimer(discoheadlights,1000,0) isLightRainbowColor = true 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