Dimos7 Posted February 15, 2017 Share Posted February 15, 2017 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
Mr.Loki Posted February 16, 2017 Share Posted February 16, 2017 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
pa3ck Posted February 16, 2017 Share Posted February 16, 2017 Rather than having 0 - off and 1 - on, there are 3 states. 0 - you let GTA handle it (when you go to a tunnel or something, it will be turned on), 1 - off, 2 - on, that's where you went wrong. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now