Jump to content

help please


Dimos7

Recommended Posts

function toggleLights(thePlayer)
   if isPedInVehicle(thePlayer) then
   car  = getPedOccupiedVehicle(thePlayer)
      if getPedOccupiedVehicleSeat(thePlayer) == 0 then
	     if getVehicleOverrideLights(car) ~= 2 then
            setVehicleOverrideLights(car, 1)
			outputChatBox(getPlayerName(thePlayer).. "has turned the lights on.", root, 255, 0, 255)
        else
            setVehicleOverrideLights(car, 0) 
			outputChatBox(getPlayerName(thePlayer).. "has turned the lights off.", root, 255, 0, 255)
	   end
	  else
	     outputChatBox("You must be on driver seat!", thePlayer, 255, 0, 0)
	  end
	else
	   outputChatBox("You must be inside a vehicle!", thePlayer, 255, 0, 0)
	end
end
addCommandHandler("lights", toggleLights)

its not working the light not turn on only off wtf no errors or warnings

Link to comment

 

 

In line 5 you are checking for 2 (Force on) but you never set the lights to 2 (Force on) in the code.

Quote

 

Returns

Returns an integer value: 0 (No override), 1 (Force off) or 2 (Force on).

 

function toggleLights(thePlayer)
	if isPedInVehicle(thePlayer) then
	local car  = getPedOccupiedVehicle(thePlayer)
		if getPedOccupiedVehicleSeat(thePlayer) == 0 then
			if getVehicleOverrideLights(car) ~= 2 then
				setVehicleOverrideLights(car, 2)
				outputChatBox(getPlayerName(thePlayer).. "has turned the lights on.", root, 255, 0, 255)
			else
				setVehicleOverrideLights(car, 1) 
				outputChatBox(getPlayerName(thePlayer).. "has turned the lights off.", root, 255, 0, 255)
			end
		else
			outputChatBox("You must be on driver seat!", thePlayer, 255, 0, 0)
		end
	else
		outputChatBox("You must be inside a vehicle!", thePlayer, 255, 0, 0)
	end
end
addCommandHandler("lights", toggleLights)

 

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