Jump to content

[HELP] Car lights issue


Dankovagabon

Recommended Posts

Hi! I recently got into scripting so I'm not really sure about what I am doing.

So I wanted to create a command that toggles the car lights, but I just can't make it work.

function carToggleLights(player, cmd)
	local driving, vehicle = isPedDrivingVehicle(player)
	if driving then
		if getVehicleOverrideLights(vehicle) ~= 2 then
			setVehicleOverrideLights(vehicle, 2)
		else
			setVehicleOverrideLights(vehicle, 1)
		end
	end
end
addCommandHandler('carlights', carToggleLights)

I would greatly appreciate if someone told me how to solve this issue. :)

Link to comment
function carToggleLights(player)
  if isPedInVehicle(player) then
      local veh = getPedOccupiedVehicle(player)
    if getVehicleOverrideLights(veh) ~= 2 then
        setVehicleOverrideLights(veh, 2)
    else
        setVehicleOverrideLights(veh, 1)
    end
  end
end
addCommandHandler("carlights", carToggleLights)

 

Edited by Dimos7
  • Like 1
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...