Enable or disable vehicles lights by pressing "L" button
local p = getVehicleController( source )
function lights()
if isPedInVehicle(source) then --if player in car then
--get the car of the controller, lets call it gat
gat = getPedOccupiedVehicle(source)
if (gat) then --check if gat is here (the vehicle)
if ( getVehicleOverrideLights ( gat ) ~= 2 ) then --check if lights arent on
setVehicleOverrideLights ( gat, 2 ) --set it on
else
setVehicleOverrideLights ( gat, 1 ) --set it off if it already on
end
end
end
end
bindKey(p, "l", "down", lights) --bind this function in L button to trigger it.
--or
addCommandHandler("lights", lights) -- trigger it by /lights
Another way
local p = getVehicleController(source)
addCommandHandler("lights",
--or
bindKey(p, "l", "down",
function()
if isPedInVehicle(source) then --if player in car then
--get the car of the controller, lets call it gat
local gat = getPedOccupiedVehicle(source)
if ( gat ) then --check if gat is here (the Vehicle)
if ( getVehicleOverrideLights ( gat ) == 0 ) or ( getVehicleOverrideLights ( playerVehicle ) == 1 ) then --check if lights arent on
setVehicleOverrideLights ( gat, 2 ) --set it on
else
setVehicleOverrideLights ( gat, 1 ) --set it off if it already on
end
end
end
end
)
https://forum.igcrpg.com/?topic=4064.msg23978#new
Just practice to myself
