local vkeys = require 'vkeys'
local lastCar = nil
local wasInCar = false
local wasDriver = false
function main()
repeat wait(0) until isSampAvailable()
while true do
wait(0)
if isCharInAnyCar(PLAYER_PED) then
local car = storeCarCharIsInNoSave(PLAYER_PED)
local model = getCarModel(car)
-- Проверка если НЕ велосипед и НЕ поезд
if not isBike(model) and not isTrain(model) then
-- Логика автоматического заведения при посадке
if not wasInCar or lastCar ~= car then
lastCar = car
wasInCar = true
lua_thread.create(function()
wait(150)
if isCharInAnyCar(PLAYER_PED) and storeCarCharIsInNoSave(PLAYER_PED) == car then
if getDriverOfCar(car) == PLAYER_PED then
wasDriver = true
if not isCarEngineOn(car) then
sampSendChat("/engine")
end
else
wasDriver = false
end
end
end)
end
-- Заведение по нажатию W если по каким-то причинам двигатель не завелся или был заглушен
if wasKeyPressed(vkeys.VK_W) then
if not sampIsCursorActive() then
if getDriverOfCar(car) == PLAYER_PED and not isCarEngineOn(car) then
sampSendChat("/engine")
end
end
end
-- Заглушение при выходе (F или Enter) + быстрый тормоз
if wasKeyPressed(vkeys.VK_F) or wasKeyPressed(vkeys.VK_RETURN) then
if not sampIsCursorActive() then
if getDriverOfCar(car) == PLAYER_PED then
-- Блок быстрого тормоза из скрипта DalBoy
lockPlayerControl(true)
wait(50)
lockPlayerControl(false)
if isCarEngineOn(car) then
sampSendChat("/engine")
end
end
end
end
end
else
wasInCar = false
wasDriver = false
lastCar = nil
end
end
end
-- Функции-фильтры моделей
function isBike(model)
local bikes = {481, 509, 510}
for _, id in ipairs(bikes) do
if model == id then return true end
end
return false
end
function isTrain(model)
local trains = {537, 538, 569, 570, 590, 449}
for _, id in ipairs(trains) do
if model == id then return true end
end
return false
end