Jump to content

[Solved] Lights [Again]


Absence2

Recommended Posts

Hey, I have came this far with my headlights script:

        --the window itself 
        lights = guiCreateWindow(211,276,322,202,"Vehicle Headlight - $2500",false) 
         
  
--edit field     
        redEdit = guiCreateEdit(110,54,142,24,"",false,lights) 
   --edit field  
        greenEdit = guiCreateEdit(110,87,143,26,"",false,lights) 
    --edit field     
        blueEdit = guiCreateEdit(108,125,149,27,"",false,lights) 
  
        --labels 
        redtx = guiCreateLabel(39,58,64,19,"Red, 0-255:",false,lights) 
        greentx = guiCreateLabel(24,93,75,19,"Green, 0-255:",false,lights) 
        bluetx = guiCreateLabel(32,129,67,17,"Blue, 0-255:",false,lights) 
         
        --purchase colored vehicle lights 
        --If Purchase button clicked, change the vehicles headlight color! 
        buyVLightsButton = guiCreateButton(97,176,70,17,"Purchase",false,lights) 
  function buyVLights( red, green, blue ) 
    red = tonumber(redEdit) 
    green = tonumber ( greenEdit ) 
    blue = tonumber ( blueEdit) 
            if red and green and blue then 
        local color = setVehicleHeadLightColor ( theVehicle, red, green, blue ) 
  outputChatBox( "You have changed your vehicle lights." ) 
  end 
  end 
  
  addEventHandler ( "onClientGUIClick",buyVLightsButton ,buyVLights, false ) 
  
         
         
        --cancel the purchase of headlights 
        cancelPurchaseButton = guiCreateButton(166,176,74,17,"Cancel",false,lights) 
function cancelPurchase()    
                destroyElement(greenEdit) 
                destroyElement(blueEdit) 
                destroyElement(redEdit) 
                destroyElement(cancelPurchaseButton) 
                destroyElement(buyVLightsButton) 
                destroyElement(lights) 
                greenEdit, blueEdit, redEdit, cancelPurchaseButton, buyVLightsButton, lights = nil   
end 
  
addEventHandler ( "onClientGUIClick",cancelPurchaseButton,cancelPurchase, false )    
   
  

Is the Edits right and how do I connect it to the buyVLightsButton ? No errors.

Trying to make so when you press "Purchase" you add vehicle lights to the vehicle

Edited by Guest
Link to comment
lights = guiCreateWindow(211,276,322,202,"Vehicle Headlight - $2500",false) 
redEdit = guiCreateEdit(110,54,142,24,"",false,lights) 
greenEdit = guiCreateEdit(110,87,143,26,"",false,lights) 
blueEdit = guiCreateEdit(108,125,149,27,"",false,lights) 
redtx = guiCreateLabel(39,58,64,19,"Red, 0-255:",false,lights) 
greentx = guiCreateLabel(24,93,75,19,"Green, 0-255:",false,lights) 
bluetx = guiCreateLabel(32,129,67,17,"Blue, 0-255:",false,lights) 
buyVLightsButton = guiCreateButton(97,176,70,17,"Purchase",false,lights) 
cancelPurchaseButton = guiCreateButton(166,176,74,17,"Cancel",false,lights) 
  
addEventHandler ( 'onClientGUIClick', root, 
    function ( ) 
        if ( source == buyVLightsButton ) then 
            local red = guiGetText ( redEdit ) 
            local green = guiGetText ( greenEdit ) 
            local blue = guiGetText ( blueEdit ) 
            if ( red and green and blue ) then 
                if ( isPedInVehicle ( localPlayer ) ) then 
                    local veh = getPedOccupiedVehicle ( localPlayer ) 
                    setVehicleHeadLightColor ( veh, red, green, blue ) 
                    outputChatBox ( 'You have changed your vehicle lights!' ) 
                else 
                    outputChatBox ( 'You are not in a vehicle!' ) 
                end 
            end 
             
        elseif ( source == cancelPurchaseButton ) then 
            guiSetVisible ( lights, false ) 
            showCursor ( false ) 
        end 
    end 
) 
  

Link to comment

Well, I'm kinda lost, I'm supposed to add this to a second GUI window.

This button >

                -- Vehicle Lights 
                bMechanicNine = guiCreateButton( 0.05, y, 0.9, 0.1, "Vehicle Headlights - $2500", true, wMechanic ) 
                addEventHandler( "onClientGUIClick", bMechanicNinje, lightTriger, false) 
                y = y + 0.1 

Then, I'm supposed to add this part over to serverside:

    function ( ) 
        if ( source == buyVLightsButton ) then 
            local red = guiGetText ( redEdit ) 
            local green = guiGetText ( greenEdit ) 
            local blue = guiGetText ( blueEdit ) 
            if ( red and green and blue ) then 
                if ( isPedInVehicle ( localPlayer ) ) then 
                    local veh = getPedOccupiedVehicle ( localPlayer ) 
                    setVehicleHeadLightColor ( veh, red, green, blue ) 
                    outputChatBox ( 'You have changed your vehicle lights!' ) 
                else 
                    outputChatBox ( 'You are not in a vehicle!' ) 
                end 
            end 
        end 
    end 
) 

Then use this:

function lightTrigger() 
    triggerServerEvent( "headlights", getLocalPlayer(), currentVehicle ) 
    closeMechanicWindow() 
end 

Any help here

Should this be the serverside part?

function headlightsColor() 
        if ( source == buyVLightsButton ) then 
            local red = guiGetText ( redEdit ) 
            local green = guiGetText ( greenEdit ) 
            local blue = guiGetText ( blueEdit ) 
            if ( red and green and blue ) then 
                if ( isPedInVehicle ( localPlayer ) ) then 
                    local veh = getPedOccupiedVehicle ( localPlayer ) 
                    setVehicleHeadLightColor ( veh, red, green, blue ) 
                    outputChatBox ( 'You have changed your vehicle lights!' ) 
                else 
                    outputChatBox ( 'You are not in a vehicle!' ) 
                end 
            end 
        end 
    end 
) 
addEvent("headlights", true) 
addEventHandler("headlights", getRootElement(), headlightsColor) 

Is all of this right? But what to do with the GUI buttons? :o

lights = guiCreateWindow(211,276,322,202,"Vehicle Headlight - $2500",false) 
redEdit = guiCreateEdit(110,54,142,24,"",false,lights) 
greenEdit = guiCreateEdit(110,87,143,26,"",false,lights) 
blueEdit = guiCreateEdit(108,125,149,27,"",false,lights) 
redtx = guiCreateLabel(39,58,64,19,"Red, 0-255:",false,lights) 
greentx = guiCreateLabel(24,93,75,19,"Green, 0-255:",false,lights) 
bluetx = guiCreateLabel(32,129,67,17,"Blue, 0-255:",false,lights) 
buyVLightsButton = guiCreateButton(97,176,70,17,"Purchase",false,lights) 
cancelPurchaseButton = guiCreateButton(166,176,74,17,"Cancel",false,lights) 

Link to comment

No, that's a mess.

-- client side:

lights = guiCreateWindow(211,276,322,202,"Vehicle Headlight - $2500",false) 
redEdit = guiCreateEdit(110,54,142,24,"",false,lights) 
greenEdit = guiCreateEdit(110,87,143,26,"",false,lights) 
blueEdit = guiCreateEdit(108,125,149,27,"",false,lights) 
redtx = guiCreateLabel(39,58,64,19,"Red, 0-255:",false,lights) 
greentx = guiCreateLabel(24,93,75,19,"Green, 0-255:",false,lights) 
bluetx = guiCreateLabel(32,129,67,17,"Blue, 0-255:",false,lights) 
buyVLightsButton = guiCreateButton(97,176,70,17,"Purchase",false,lights) 
cancelPurchaseButton = guiCreateButton(166,176,74,17,"Cancel",false,lights) 
  
addEventHandler ( 'onClientGUIClick', root, 
    function ( ) 
        if ( source == buyVLightsButton ) then 
            local red = guiGetText ( redEdit ) 
            local green = guiGetText ( greenEdit ) 
            local blue = guiGetText ( blueEdit ) 
            if ( red and green and blue ) then 
                if ( isPedInVehicle ( localPlayer ) ) then 
                    local veh = getPedOccupiedVehicle ( localPlayer ) 
                    triggerServerEvent("onHeadLightsChange",localPlayer,veh,red,green,blue) 
                else 
                    outputChatBox ( 'You are not in a vehicle!' ) 
                end 
            end            
        elseif ( source == cancelPurchaseButton ) then 
            guiSetVisible ( lights, false ) 
            showCursor ( false ) 
        end 
    end 
) 

-- server side:

addEvent("onHeadLightsChange",true) 
addEventHandler("onHeadLightsChange",root, 
    function (currentVehicle, red, green, blue) 
        if (currentVehicle) then 
            setVehicleHeadLightColor ( currentVehicle, tonumber(red) or 255, tonumber(green) or 255, tonumber(blue) or 255 ) 
            outputChatBox ( 'You have changed your vehicle lights!', source ) 
        end 
    end 
) 

Link to comment

Well as I said, I have to trigger the window with this button, if not, it has to stay hidden,

                -- Vehicle Lights 
                bMechanicNine = guiCreateButton( 0.05, y, 0.9, 0.1, "Vehicle Headlights - $2500", true, wMechanic ) 
                addEventHandler( "onClientGUIClick", bMechanicNinje, lightTriger, false) 
                y = y + 0.1 

then this (I get syntax error at function, line 2)

addEventHandler ( 'onClientGUIClick', root, 
    function lightTriger () 
        if ( source == buyVLightsButton ) then 
            local red = guiGetText ( redEdit ) 
            local green = guiGetText ( greenEdit ) 
            local blue = guiGetText ( blueEdit ) 
            if ( red and green and blue ) then 
                if ( isPedInVehicle ( localPlayer ) ) then 
                    local veh = getPedOccupiedVehicle ( localPlayer ) 
                    triggerServerEvent("onHeadLightsChange",localPlayer,veh,red,green,blue) 
                else 
                    outputChatBox ( 'You are not in a vehicle!' ) 
                end 
            end           
        elseif ( source == cancelPurchaseButton ) then 
            guiSetVisible ( lights, false ) 
            showCursor ( false ) 
        end 
    end 
) 

Poked around with it and doesn't seem to fix o.O

Link to comment
Well as I said, I have to trigger the window with this button, if not, it has to stay hidden,
                -- Vehicle Lights 
                bMechanicNine = guiCreateButton( 0.05, y, 0.9, 0.1, "Vehicle Headlights - $2500", true, wMechanic ) 
                addEventHandler( "onClientGUIClick", bMechanicNinje, lightTriger, false) 
                y = y + 0.1 

then this (I get syntax error at function, line 2)

addEventHandler ( 'onClientGUIClick', root, 
    function lightTriger () 
        if ( source == buyVLightsButton ) then 
            local red = guiGetText ( redEdit ) 
            local green = guiGetText ( greenEdit ) 
            local blue = guiGetText ( blueEdit ) 
            if ( red and green and blue ) then 
                if ( isPedInVehicle ( localPlayer ) ) then 
                    local veh = getPedOccupiedVehicle ( localPlayer ) 
                    triggerServerEvent("onHeadLightsChange",localPlayer,veh,red,green,blue) 
                else 
                    outputChatBox ( 'You are not in a vehicle!' ) 
                end 
            end           
        elseif ( source == cancelPurchaseButton ) then 
            guiSetVisible ( lights, false ) 
            showCursor ( false ) 
        end 
    end 
) 

Poked around with it and doesn't seem to fix o.O

You can't put function name.

It have to be:

addEventHandler ( 'eventName', root, 
     function ( ) 
          -- Something here 
     end 
) 

Link to comment
lights = guiCreateWindow(211,276,322,202,"Vehicle Headlight - $2500",false) 
guiSetVisible(lights, false) 
redEdit = guiCreateEdit(110,54,142,24,"",false,lights) 
greenEdit = guiCreateEdit(110,87,143,26,"",false,lights) 
blueEdit = guiCreateEdit(108,125,149,27,"",false,lights) 
redtx = guiCreateLabel(39,58,64,19,"Red, 0-255:",false,lights) 
greentx = guiCreateLabel(24,93,75,19,"Green, 0-255:",false,lights) 
bluetx = guiCreateLabel(32,129,67,17,"Blue, 0-255:",false,lights) 
buyVLightsButton = guiCreateButton(97,176,70,17,"Purchase",false,lights) 
cancelPurchaseButton = guiCreateButton(166,176,74,17,"Cancel",false,lights) 
  
addEventHandler ( 'onClientGUIClick', root, 
    function ( ) 
        if (source == bMechanicNine ) then 
            guiSetVisible(lights, true) 
        elseif ( source == buyVLightsButton ) then 
            local red = guiGetText ( redEdit ) 
            local green = guiGetText ( greenEdit ) 
            local blue = guiGetText ( blueEdit ) 
            if ( red and green and blue ) then 
                if ( isPedInVehicle ( localPlayer ) ) then 
                    local veh = getPedOccupiedVehicle ( localPlayer ) 
                    triggerServerEvent("onHeadLightsChange",localPlayer,veh,red,green,blue) 
                else 
                    outputChatBox ( 'You are not in a vehicle!' ) 
                end 
            end           
        elseif ( source == cancelPurchaseButton ) then 
            guiSetVisible ( lights, false ) 
            showCursor ( false ) 
        end 
    end 
) 

Link to comment
lights = guiCreateWindow(211,276,322,202,"Vehicle Headlight - $2500",false) 
guiSetVisible(lights, false) 
redEdit = guiCreateEdit(110,54,142,24,"",false,lights) 
greenEdit = guiCreateEdit(110,87,143,26,"",false,lights) 
blueEdit = guiCreateEdit(108,125,149,27,"",false,lights) 
redtx = guiCreateLabel(39,58,64,19,"Red, 0-255:",false,lights) 
greentx = guiCreateLabel(24,93,75,19,"Green, 0-255:",false,lights) 
bluetx = guiCreateLabel(32,129,67,17,"Blue, 0-255:",false,lights) 
buyVLightsButton = guiCreateButton(97,176,70,17,"Purchase",false,lights) 
cancelPurchaseButton = guiCreateButton(166,176,74,17,"Cancel",false,lights) 
  
addEventHandler ( 'onClientGUIClick', root, 
    function ( ) 
        if (source == bMechanicNine ) then 
            guiSetVisible(lights, true) 
        elseif ( source == buyVLightsButton ) then 
            local red = guiGetText ( redEdit ) 
            local green = guiGetText ( greenEdit ) 
            local blue = guiGetText ( blueEdit ) 
            if ( red and green and blue ) then 
                if ( isPedInVehicle ( localPlayer ) ) then 
                    local veh = getPedOccupiedVehicle ( localPlayer ) 
                    triggerServerEvent("onHeadLightsChange",localPlayer,veh,red,green,blue) 
                else 
                    outputChatBox ( 'You are not in a vehicle!' ) 
                end 
            end           
        elseif ( source == cancelPurchaseButton ) then 
            guiSetVisible ( lights, false ) 
            showCursor ( false ) 
        end 
    end 
) 

didn't work, it shows all the time on resource start and buttons stopped working =/

@Draken, I didn't really catch ya there, what do you mean?

Link to comment
lights = guiCreateWindow(211,276,322,202,"Vehicle Headlight - $2500",false) 
guiSetVisible(lights, false) 
redEdit = guiCreateEdit(110,54,142,24,"",false,lights) 
greenEdit = guiCreateEdit(110,87,143,26,"",false,lights) 
blueEdit = guiCreateEdit(108,125,149,27,"",false,lights) 
redtx = guiCreateLabel(39,58,64,19,"Red, 0-255:",false,lights) 
greentx = guiCreateLabel(24,93,75,19,"Green, 0-255:",false,lights) 
bluetx = guiCreateLabel(32,129,67,17,"Blue, 0-255:",false,lights) 
buyVLightsButton = guiCreateButton(97,176,70,17,"Purchase",false,lights) 
cancelPurchaseButton = guiCreateButton(166,176,74,17,"Cancel",false,lights) 
  
addEventHandler ( 'onClientGUIClick', root, 
    function ( ) 
        if (source == bMechanicNine ) then 
            guiSetVisible(lights, true) 
        elseif ( source == buyVLightsButton ) then 
            local red = guiGetText ( redEdit ) 
            local green = guiGetText ( greenEdit ) 
            local blue = guiGetText ( blueEdit ) 
            if ( red and green and blue ) then 
                if ( isPedInVehicle ( localPlayer ) ) then 
                    local veh = getPedOccupiedVehicle ( localPlayer ) 
                    triggerServerEvent("onHeadLightsChange",localPlayer,veh,red,green,blue) 
                else 
                    outputChatBox ( 'You are not in a vehicle!' ) 
                end 
            end           
        elseif ( source == cancelPurchaseButton ) then 
            guiSetVisible ( lights, false ) 
            showCursor ( false ) 
        end 
    end 
) 

didn't work, it shows all the time on resource start and buttons stopped working =/

@Draken, I didn't really catch ya there, what do you mean?

When you use like this:

addEventHandler ( 'eventName', root, 
     ----  
     ----  
     end 
) 

You can't put like

function example() 

You can't put name in functions.

Example of correct script:

addEventHandler ( 'onResourceStart', root, 
      function() 
           -- Something 
      end 
) 

Link to comment
Are you sure? because it didn't show the window when I tested it.

I wasn't sure :(

I messed up badly, I had missed to erase a few parts which duplicated the windows multiple times,

I have no freaking idea how I could of missed that, LOL.

Like this:

lights = guiCreateWindow(211,276,322,202,"Vehicle Headlight - $2500",false) 
guiSetVisible(lights, false) 
redEdit = guiCreateEdit(110,54,142,24,"",false,lights) 
greenEdit = guiCreateEdit(110,87,143,26,"",false,lights) 
blueEdit = guiCreateEdit(108,125,149,27,"",false,lights) 
redtx = guiCreateLabel(39,58,64,19,"Red, 0-255:",false,lights) 
greentx = guiCreateLabel(24,93,75,19,"Green, 0-255:",false,lights) 
bluetx = guiCreateLabel(32,129,67,17,"Blue, 0-255:",false,lights) 
buyVLightsButton = guiCreateButton(97,176,70,17,"Purchase",false,lights) 
cancelPurchaseButton = guiCreateButton(166,176,74,17,"Cancel",false,lights) 
lights = guiCreateWindow(211,276,322,202,"Vehicle Headlight - $2500",false) 
guiSetVisible(lights, false) 
redEdit = guiCreateEdit(110,54,142,24,"",false,lights) 
greenEdit = guiCreateEdit(110,87,143,26,"",false,lights) 
blueEdit = guiCreateEdit(108,125,149,27,"",false,lights) 
redtx = guiCreateLabel(39,58,64,19,"Red, 0-255:",false,lights) 
greentx = guiCreateLabel(24,93,75,19,"Green, 0-255:",false,lights) 
bluetx = guiCreateLabel(32,129,67,17,"Blue, 0-255:",false,lights) 
buyVLightsButton = guiCreateButton(97,176,70,17,"Purchase",false,lights) 
cancelPurchaseButton = guiCreateButton(166,176,74,17,"Cancel",false,lights) 
lights = guiCreateWindow(211,276,322,202,"Vehicle Headlight - $2500",false) 
guiSetVisible(lights, false) 
redEdit = guiCreateEdit(110,54,142,24,"",false,lights) 
greenEdit = guiCreateEdit(110,87,143,26,"",false,lights) 
blueEdit = guiCreateEdit(108,125,149,27,"",false,lights) 
redtx = guiCreateLabel(39,58,64,19,"Red, 0-255:",false,lights) 
greentx = guiCreateLabel(24,93,75,19,"Green, 0-255:",false,lights) 
bluetx = guiCreateLabel(32,129,67,17,"Blue, 0-255:",false,lights) 
buyVLightsButton = guiCreateButton(97,176,70,17,"Purchase",false,lights) 
cancelPurchaseButton = guiCreateButton(166,176,74,17,"Cancel",false,lights) 
lights = guiCreateWindow(211,276,322,202,"Vehicle Headlight - $2500",false) 
guiSetVisible(lights, false) 
redEdit = guiCreateEdit(110,54,142,24,"",false,lights) 
greenEdit = guiCreateEdit(110,87,143,26,"",false,lights) 
blueEdit = guiCreateEdit(108,125,149,27,"",false,lights) 
redtx = guiCreateLabel(39,58,64,19,"Red, 0-255:",false,lights) 
greentx = guiCreateLabel(24,93,75,19,"Green, 0-255:",false,lights) 
bluetx = guiCreateLabel(32,129,67,17,"Blue, 0-255:",false,lights) 
buyVLightsButton = guiCreateButton(97,176,70,17,"Purchase",false,lights) 
cancelPurchaseButton = guiCreateButton(166,176,74,17,"Cancel",false,lights) 
  
addEventHandler ( 'onClientGUIClick', root, 
    function ( ) 
        if (source == bMechanicNine ) then 
            guiSetVisible(lights, true) 
        elseif ( source == buyVLightsButton ) then 
            local red = guiGetText ( redEdit ) 
            local green = guiGetText ( greenEdit ) 
            local blue = guiGetText ( blueEdit ) 
            if ( red and green and blue ) then 
                if ( isPedInVehicle ( localPlayer ) ) then 
                    local veh = getPedOccupiedVehicle ( localPlayer ) 
                    triggerServerEvent("onHeadLightsChange",localPlayer,veh,red,green,blue) 
                else 
                    outputChatBox ( 'You are not in a vehicle!' ) 
                end 
            end           
        elseif ( source == cancelPurchaseButton ) then 
            guiSetVisible ( lights, false ) 
            showCursor ( false ) 
        end 
    end 
) 

Now I just need to figure out how to hide it after pressing 'Purchase' :/, any ideas? (It's not in the clientside part so I'm lost :D)

Link to comment
Use triggerClientEvent in the server side, that'll trigger a event to the client side where you can use guiSetVisible.

Oh okay,

can you help me with one last thing then?

addEvent("onHeadLightsChange",true) 
addEventHandler("onHeadLightsChange",root, 
    function (currentVehicle, red, green, blue) 
            if (currentVehicle) then 
               if exports.global:hasMoney(player, 2500) then 
                exports.global:takeMoney(player, 2500) 
            setVehicleHeadLightColor ( currentVehicle, tonumber(red) or 255, tonumber(green) or 255, tonumber(blue) or 255 ) 
            outputChatBox ( 'You have changed your vehicle lights!', source ) 
            else 
            outputChatBox ( 'Not Enough Cash!', source ) 
        end 
    end 
end 
) 

It doesn't let me Purchase lights with or without the money,

gives me the second message, "Not Enough Cash!"

also, can I set it so only numbers are allowed in the Edit field?

Link to comment
addEvent("onHeadLightsChange",true) 
addEventHandler("onHeadLightsChange",root, 
    function (currentVehicle, red, green, blue) 
        if (currentVehicle) then 
            if exports.global:hasMoney(source, 2500) then -- Your player argument is 'source' not 'player. 
                exports.global:takeMoney(source, 2500) -- Your player argument is 'source' not 'player. 
                setVehicleHeadLightColor ( currentVehicle, tonumber(red) or 255, tonumber(green) or 255, tonumber(blue) or 255 ) 
                outputChatBox ( 'You have changed your vehicle lights!', source ) 
                else 
                outputChatBox ( 'Not Enough Cash!', source ) 
            end 
        end 
    end 
) 

Link to comment

Your player argument is 'source' not 'player.

/facepalm

=/

Well, that's about it but I did find an issue that I don't know to fix.

if one edit field is blank (No 0 that is),

like

255

255

or

--< blank

255

The color becomes white and they have to pay for it. Can I fix this somehow? Forcing them to type something in if they want to hit the "Purchase" Button or auto change to 0 if it's blank?

Link to comment

Try this:

lights = guiCreateWindow(211,276,322,202,"Vehicle Headlight - $2500",false) 
guiSetVisible(lights, false) 
redEdit = guiCreateEdit(110,54,142,24,"",false,lights) 
greenEdit = guiCreateEdit(110,87,143,26,"",false,lights) 
blueEdit = guiCreateEdit(108,125,149,27,"",false,lights) 
redtx = guiCreateLabel(39,58,64,19,"Red, 0-255:",false,lights) 
greentx = guiCreateLabel(24,93,75,19,"Green, 0-255:",false,lights) 
bluetx = guiCreateLabel(32,129,67,17,"Blue, 0-255:",false,lights) 
buyVLightsButton = guiCreateButton(97,176,70,17,"Purchase",false,lights) 
cancelPurchaseButton = guiCreateButton(166,176,74,17,"Cancel",false,lights) 
  
addEventHandler ( 'onClientGUIClick', root, 
    function ( ) 
        if (source == bMechanicNine ) then 
            guiSetVisible(lights, true) 
        elseif ( source == buyVLightsButton ) then 
            local red = guiGetText ( redEdit ) 
            local green = guiGetText ( greenEdit ) 
            local blue = guiGetText ( blueEdit ) 
            if ( red ~= "" and green ~= "" and blue ~= "" and tonumber(red) and tonumber(green) and tonumber(blue) ) then 
                if ( isPedInVehicle ( localPlayer ) ) then 
                    local veh = getPedOccupiedVehicle ( localPlayer ) 
                    triggerServerEvent("onHeadLightsChange",localPlayer,veh,red,green,blue) 
                else 
                    outputChatBox ( 'You are not in a vehicle!' ) 
                end 
            end           
        elseif ( source == cancelPurchaseButton ) then 
            guiSetVisible ( lights, false ) 
            showCursor ( false ) 
        end 
    end 
) 

Link to comment
Try this:
lights = guiCreateWindow(211,276,322,202,"Vehicle Headlight - $2500",false) 
guiSetVisible(lights, false) 
redEdit = guiCreateEdit(110,54,142,24,"",false,lights) 
greenEdit = guiCreateEdit(110,87,143,26,"",false,lights) 
blueEdit = guiCreateEdit(108,125,149,27,"",false,lights) 
redtx = guiCreateLabel(39,58,64,19,"Red, 0-255:",false,lights) 
greentx = guiCreateLabel(24,93,75,19,"Green, 0-255:",false,lights) 
bluetx = guiCreateLabel(32,129,67,17,"Blue, 0-255:",false,lights) 
buyVLightsButton = guiCreateButton(97,176,70,17,"Purchase",false,lights) 
cancelPurchaseButton = guiCreateButton(166,176,74,17,"Cancel",false,lights) 
  
addEventHandler ( 'onClientGUIClick', root, 
    function ( ) 
        if (source == bMechanicNine ) then 
            guiSetVisible(lights, true) 
        elseif ( source == buyVLightsButton ) then 
            local red = guiGetText ( redEdit ) 
            local green = guiGetText ( greenEdit ) 
            local blue = guiGetText ( blueEdit ) 
            if ( red ~= "" and green ~= "" and blue ~= "" and tonumber(red) and tonumber(green) and tonumber(blue) ) then 
                if ( isPedInVehicle ( localPlayer ) ) then 
                    local veh = getPedOccupiedVehicle ( localPlayer ) 
                    triggerServerEvent("onHeadLightsChange",localPlayer,veh,red,green,blue) 
                else 
                    outputChatBox ( 'You are not in a vehicle!' ) 
                end 
            end           
        elseif ( source == cancelPurchaseButton ) then 
            guiSetVisible ( lights, false ) 
            showCursor ( false ) 
        end 
    end 
) 

Works, thanks so much for your help :D, once again, not the first time you've saved my day.

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...