Lua Транспорт [ARZ] AutoEngine - Автоматический завод двигателя

кириешки

Участник
Автор темы
24
4
Версия SA-MP
  1. 0.3.7 (R1)
Описание:
Простенький скрипт который заводит автомобиль когда вы в него садитесь.
После того, как вы сели в авто, скрипт перестает ждать пока вы сядете в авто (чтоб не было лишних багов).

Активация/Дективация: /ae
 

Вложения

  • AutoEngine.lua
    785 байт · Просмотры: 214
  • Нравится
Реакции: MLycoris

MLycoris

На вид оружие массового семяизвержения
Проверенный
2,051
2,302
ну или так тоже можно
Lua:
require('lib.samp.events').onSendEnterVehicle = function(vehicleId, passenger)
    lua_thread.create(function()
        while not isCharInAnyCar(1) do wait(100) end
        if not isCarEngineOn(storeCarCharIsInNoSave(1)) then
            sampSendChat("/engine")
        end
   end)
end
 

blsthk221

Новичок
1
1
Лучше так. Активацию лень было прикручивать

AutoEngine 2026:
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
 

Вложения

  • Autoengine.lua
    3.2 KB · Просмотры: 9