Hi guys, i have a problem that i need help to fix it. So in this script i have lights and engine to turn off or on, but the lights works fine and engine just give me a message and dont set to engine off or on, basically engine dont work. With addCommandHandler everything works, but what i want is bindKeys.
Thanks in advance for any help!
--//Engine On / Off
function engine (src, cmd)
if getPedOccupiedVehicle (src) and getPedOccupiedVehicleSeat (src) == 0 then
local vehicle = getPedOccupiedVehicle (src)
if getVehicleEngineState (vehicle) 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)
addEventHandler ("onVehicleStartEnter", getRootElement(),
function()
bindKey (source, "j", "down", engine)
end)
--//--
--//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)
addEventHandler ("onPlayerVehicleEnter", getRootElement(),
function()
bindKey (source, "l", "down", lights)
end)