Jump to content

Headlight states.


DzMG-LV

Recommended Posts

So i made script when vehicle have headlight states

1-Tilting down

2-Tilting up

3-Off

It switches from 1 to 2, but i can't switch them off (to 3)

  
  
function toggleLights(source, key, keystate) 
    local veh = getPedOccupiedVehicle(source) 
    local inVehicle = getElementData(source, "realinvehicle") 
  
    if (veh) and (inVehicle==1) then 
        local model = getElementModel(veh) 
        if not (lightlessVehicle[model]) then 
            local lights = getVehicleOverrideLights(veh) 
            local seat = getPedOccupiedVehicleSeat(source) 
  
            if (seat==0) then 
                if (lights~=3) then 
                    setVehicleOverrideLights(veh, 2) 
                    exports['anticheat-system']:changeProtectedElementDataEx(veh, "lights", 2, true) 
                if (lights~=2) then 
                    setVehicleOverrideLights(veh, 2) 
                    exports['anticheat-system']:changeProtectedElementDataEx(veh, "lights", 1, true) 
                if (lights~=1) then 
                    setVehicleOverrideLights(veh, 1) 
                    exports['anticheat-system']:changeProtectedElementDataEx(veh, "lights", 0, true) 
                end 
            end 
        end 
    end 
end 
end 
end 
addCommandHandler("lights", toggleLights, true) 
addEvent('togLightsVehicle', true) 
addEventHandler('togLightsVehicle', root, 
    function() 
        toggleLights(client) 
    end) 
  

Link to comment

I can switch from Tilting down to tilting up, but i can't switch them off. thats my problem

Tilting Down:

0ZzxKfN.png

Tilting Up:

F2UZqAL.png

It needs work like this.

First when u press L u have TIlting Down state, when u press again L u have Tilting Up state but when u press third time ur lights switches off, but i cant switch them off.

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...