Absence2 Posted March 2, 2012 Share Posted March 2, 2012 Hello, I've been trying to figure out how to attach: function changeCarLightsColor ( thePlayer, command, red, green, blue ) local theVehicle = getPedOccupiedVehicle ( thePlayer ) if ( not theVehicle ) then return outputChatBox( "SYNTAX: /carlights [color1] [color2] [color3]", thePlayer, 255, 194, 14 ) end red = tonumber ( red ) green = tonumber ( green ) blue = tonumber ( blue ) -- check if the colour values for red, green and blue are valid if red and green and blue then local color = setVehicleHeadLightColor ( theVehicle, red, green, blue ) if(not color) then outputChatBox( "SYNTAX: /carlights [color1] [color2] [color3]", thePlayer, 255, 194, 14 ) else outputChatBox ( "Vehicle lights color changed sucessfully", thePlayer, 255, 194, 14 ) end else outputChatBox( "SYNTAX: /carlights [color1] [color2] [color3]", thePlayer, 255, 194, 14 ) end end addCommandHandler ( "carlights", changeCarLightsColor ) To a GUI, The GUI I am using is: addEventHandler("onClientResourceStart",resourceRoot, function() GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Label = {} GUIEditor_Edit = {} GUIEditor_Window[1] = guiCreateWindow(281,193,320,236,"Vehicle Headlights",false) GUIEditor_Edit[1] = guiCreateEdit(74,70,163,26,"",false,GUIEditor_Window[1]) GUIEditor_Edit[2] = guiCreateEdit(75,127,164,26,"",false,GUIEditor_Window[1]) GUIEditor_Edit[3] = guiCreateEdit(76,184,164,28,"",false,GUIEditor_Window[1]) GUIEditor_Label[1] = guiCreateLabel(76,43,158,18,"Red, 0-255",false,GUIEditor_Window[1]) GUIEditor_Label[2] = guiCreateLabel(75,103,160,19,"Green, 0-255",false,GUIEditor_Window[1]) GUIEditor_Label[3] = guiCreateLabel(79,160,131,21,"Blue, 0-255",false,GUIEditor_Window[1]) GUIEditor_Button[1] = guiCreateButton(250,184,57,40,"Close",false,GUIEditor_Window[1]) GUIEditor_Button[2] = guiCreateButton(250,145,55,29,"Buy Lights",false,GUIEditor_Window[1]) end ) How do I make the guiEdits functionable? Link to comment
Kenix Posted March 2, 2012 Share Posted March 2, 2012 How do I make the guiEdits functionable? What you mean? You mean this https://wiki.multitheftauto.com/wiki/OnClientGUIChanged ? Link to comment
Absence2 Posted March 2, 2012 Author Share Posted March 2, 2012 How do I make the guiEdits functionable? What you mean? You mean this https://wiki.multitheftauto.com/wiki/OnClientGUIChanged ? I think so but I still don't understand how to do it EDIT: It seems way too hard for me to be honest, so I decided to add the command while inside a specific marker (I'm using these for jobs originally, that's why there's Bus thingies, trying to fix the main thing first). So this is what I got: local jobmarker13 = createMarker ( 737.0986328125, -1344.3818359375, 12.518682479858, "cylinder", 1.3, 255, 255, 153, 15 ) function renderRectangleCar() local screenWidth, screenHeight = guiGetScreenSize() local nSw,nSh = guiGetScreenSize( ) local rootElement = getRootElement() local x,y = guiGetScreenSize() -- Get players resolution. --Draw texts and background dxDrawRectangle ( x/3.3, y/1.59, x/2.2, y/4.35, tocolor ( 255, 255, 255, 60 ) ) dxDrawRectangle ( x/3.4, y/1.6, x/2.13, y/4.2, tocolor ( 0, 0, 0, 150 ) ) dxDrawText("Los Santos Bus Driver Job",nSw/3, nSh/1.57, nSw, nSh,tocolor(0,255,255,185),0.7,"bankgothic","left","top",false,false,false) dxDrawText("Use /acceptjob to accept this job",nSw/3, nSh/1.47, nSw, nSh,tocolor(255,255,255,185),0.55,"bankgothic","left","top",false,false,false) dxDrawText("Objective: Drive your route with bus ",nSw/3, nSh/1.3, nSw, nSh,tocolor(255,255,255,185),0.48,"bankgothic","left","top",false,false,false) dxDrawText("Job Pays: 95$ per stop (( Checkpoint )) ",nSw/3, nSh/1.25, nSw, nSh,tocolor(255,255,255,185),0.48,"bankgothic","left","top",false,false,false) dxDrawText("/quitjob if this job doesn't suit you",nSw/3, nSh/1.2, nSw, nSh,tocolor(255,0,0,185),0.48,"bankgothic","left","top",false,false,false) end --Add text on markerHit function jobmarker13Hit () if isElementWithinMarker(localPlayer, jobmarker13) then addEventHandler("onClientRender",root,renderRectangleCar) outputChatBox(" [English] Peter Edwards says: Hello there, you interested in a job?", 255, 255, 255) end end addEventHandler( "onClientMarkerHit", jobmarker13, jobmarker13Hit ) --Hide dxDrawings upon markerLeave function jobmarker13Leave () removeEventHandler("onClientRender",root,renderRectangleCar) end addEventHandler( "onClientMarkerLeave", jobmarker13, jobmarker13Leave ) --acceptjob command while inside marker function useLight() if isElementWithinMarker(localPlayer, jobmarker13) then local theVehicle = getPedOccupiedVehicle ( thePlayer ) if ( not theVehicle ) then return outputChatBox( "SYNTAX: /carlights [color1] [color2] [color3]", thePlayer, 255, 194, 14 ) end red = tonumber ( red ) green = tonumber ( green ) blue = tonumber ( blue ) -- check if the colour values for red, green and blue are valid if red and green and blue then local color = setVehicleHeadLightColor ( theVehicle, red, green, blue ) if(not color) then outputChatBox( "SYNTAX: /carlights [color1] [color2] [color3]", thePlayer, 255, 194, 14 ) else outputChatBox ( "Vehicle lights color changed sucessfully", thePlayer, 255, 194, 14 ) end else outputChatBox( "SYNTAX: /carlights [color1] [color2] [color3]", thePlayer, 255, 194, 14 ) end end end addCommandHandler("carlights", useLight) But isn't working, 39: bad argument @ 'isElementWithinMarker' gives the error while outside the marker & inside and doesn't change the vehicle lights. Link to comment
HunT Posted March 2, 2012 Share Posted March 2, 2012 U can use the cpicker by aibo for car color and light . here : https://community.multitheftauto.com/index.php?p= ... ls&id=3247 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