addEventHandler("onPlayerLogin", root, function()
bindKey(source, "l", "down", lights)
bindKey(source, "j", "down", engine)
end)
addEventHandler("onResourceStart", resourceRoot, function()
for _, v in pairs (getElementsByType("player")) do
bindKey(v, "l", "down", lights)
bindKey(v, "j", "down", engine)
end
end)
--//Engine On / Off
function engine (src, cmd)
if getPedOccupiedVehicle (src) and getPedOccupiedVehicleSeat (src) == 0 then
local vehicle = getPedOccupiedVehicle (src)
if getVehicleEngineState (vehicle) == true then
setVehicleEngineState (vehicle, false)
outputChatBox ("Motor ligado!", src, 255, 0, 0)
else
setVehicleEngineState (vehicle, true)
outputChatBox ("Motor desligado!", src, 0, 255, 0)
end
else
return false
end
end
addCommandHandler ("motor", engine)
--//--
--//Vehicle Lights
function lights (src, cmd)
if getPedOccupiedVehicle (src) and getPedOccupiedVehicleSeat (src) == 0 then
local vehicle = getPedOccupiedVehicle (src)
if getVehicleOverrideLights (vehicle) == 1 then
setVehicleOverrideLights (vehicle, 2)
outputChatBox ("Luzes ligadas!", src, 0, 255, 0)
else
setVehicleOverrideLights (vehicle, 1)
outputChatBox ("Luzes desligadas!", src, 255, 0, 0)
end
else
return false
end
end
addCommandHandler ("luzes", lights)