local function toggleLight(player)
local plane = getPedOccupiedVehicle(player)
if (plane) then
local lightMarker = getElementData(plane, "lightMarker")
if (isElement(lightMarker) then -- disable light
destroyElement(lightMarker)
removeElementData(plane, "lightMarker")
return
end
-- enable light
local x,y,z = getElementPosition(plane)
local lightMarker = createMarker(x,y,z - 1, 'corona', 1, 255,255,255,150)
attachElements(lightMarker, plane, 4, 3, -2)
setElementData(plane, "lightMarker", lightMarker, false)
end
end
addEventHandler('onVehicleEnter', root, function(seat,plr)
if (seat == 0 and getElementModel(source) == 553) then
bindKey(plr, "3", "down", toggleLight)
end
end)
addEventHandler('onVehicleExit', root, function(seat,plr)
if (seat == 0 and getElementModel(source) == 553) then
unbindKey(plr, "3", "down", toggleLight)
end
end)