Teste lá :
function triggerVehicleSystem(sys)
local veh = getPedOccupiedVehicle(source)
if veh and getVehicleController(veh) == source then
if sys == "engine" then
if not getElementData(veh,"Gasolina") then setVehicleEngineState(veh, not getVehicleEngineState(veh)) return end
if getElementData(veh,"Gasolina") > 0 then
setVehicleEngineState(veh, not getVehicleEngineState(veh))
else
outputChatBox("Нет бензина!",source,200,0,0)
end
elseif sys == "lights" then
if getVehicleOverrideLights( veh ) ~= 2 then
setVehicleOverrideLights( veh, 2 )
else
setVehicleOverrideLights( veh, 1 )
end
elseif sys == "lock" then
setVehicleLocked(veh,not isVehicleLocked(veh))
end
end
end
addEvent("triggerVehicleSystem",true)
addEventHandler("triggerVehicleSystem",root,triggerVehicleSystem)
--# Adicionado :
local estado_do_motor = { }
addEventHandler ( "onPlayerVehicleExit", getRootElement ( ), function ( veh, seat, jacked )
if seat == 0 then
if estado_do_motor[veh] == "true" then
setVehicleEngineState ( veh, true )
else
setVehicleEngineState ( veh, false )
end
end
end)
--# Verifica o Motor, ao Começa a Sair do Veiculo.
addEventHandler ( "onVehicleStartExit", getRootElement ( ), function ( thePlayer, seat, jacked )
if seat == 0 then
local veh = getPedOccupiedVehicle(thePlayer)
estado_do_motor[veh] = tostring(getVehicleEngineState(veh))
end
end)
addEventHandler ( "onPlayerVehicleEnter", getRootElement ( ), function ( veh, seat, jacked )
if seat == 0 then
if estado_do_motor[veh] == "true" then
setVehicleEngineState ( veh, true )
else
setVehicleEngineState ( veh, false )
end
end
end)
--# Verifica o Motor, ao Começar a Entrar no Veiculo.
addEventHandler ( "onVehicleStartEnter", getRootElement ( ), function ( thePlayer, seat, jacked )
if seat == 0 then
local veh = getPedOccupiedVehicle(thePlayer)
estado_do_motor[veh] = tostring(getVehicleEngineState(veh))
end
end)