Вопросы по Lua скриптингу

Общая тема для вопросов по разработке скриптов на языке программирования Lua, в частности под MoonLoader.
  • Задавая вопрос, убедитесь, что его нет в списке частых вопросов и что на него ещё не отвечали (воспользуйтесь поиском).
  • Поищите ответ в теме посвященной разработке Lua скриптов в MoonLoader
  • Отвечая, убедитесь, что ваш ответ корректен.
  • Старайтесь как можно точнее выразить мысль, а если проблема связана с кодом, то обязательно прикрепите его к сообщению, используя блок [code=lua]здесь мог бы быть ваш код[/code].
  • Если вопрос связан с MoonLoader-ом первым делом желательно поискать решение на wiki.

Частые вопросы

Как научиться писать скрипты? С чего начать?
Информация - Гайд - Всё о Lua скриптинге для MoonLoader(https://blast.hk/threads/22707/)
Как вывести текст на русском? Вместо русского текста у меня какие-то каракули.
Изменить кодировку файла скрипта на Windows-1251. В Atom: комбинация клавиш Ctrl+Shift+U, в Notepad++: меню Кодировки -> Кодировки -> Кириллица -> Windows-1251.
Как получить транспорт, в котором сидит игрок?
Lua:
local veh = storeCarCharIsInNoSave(PLAYER_PED)
Как получить свой id или id другого игрока?
Lua:
local _, id = sampGetPlayerIdByCharHandle(PLAYER_PED) -- получить свой ид
local _, id = sampGetPlayerIdByCharHandle(ped) -- получить ид другого игрока. ped - это хендл персонажа
Как проверить, что строка содержит какой-то текст?
Lua:
if string.find(str, 'текст', 1, true) then
-- строка str содержит "текст"
end
Как эмулировать нажатие игровой клавиши?
Lua:
local game_keys = require 'game.keys' -- где-нибудь в начале скрипта вне функции main

setGameKeyState(game_keys.player.FIREWEAPON, -1) -- будет сэмулировано нажатие клавиши атаки
Все иды клавиш находятся в файле moonloader/lib/game/keys.lua.
Подробнее о функции setGameKeyState здесь: lua - setgamekeystate | BlastHack — DEV_WIKI(https://www.blast.hk/wiki/lua:setgamekeystate)
Как получить id другого игрока, в которого целюсь я?
Lua:
local valid, ped = getCharPlayerIsTargeting(PLAYER_HANDLE) -- получить хендл персонажа, в которого целится игрок
if valid and doesCharExist(ped) then -- если цель есть и персонаж существует
  local result, id = sampGetPlayerIdByCharHandle(ped) -- получить samp-ид игрока по хендлу персонажа
  if result then -- проверить, прошло ли получение ида успешно
    -- здесь любые действия с полученным идом игрока
  end
end
Как зарегистрировать команду чата SAMP?
Lua:
-- До бесконечного цикла/задержки
sampRegisterChatCommand("mycommand", function (param)
     -- param будет содержать весь текст введенный после команды, чтобы разделить его на аргументы используйте string.match()
    sampAddChatMessage("MyCMD", -1)
end)
Крашит игру при вызове sampSendChat. Как это исправить?
Это происходит из-за бага в SAMPFUNCS, когда производится попытка отправки пакета определенными функциями изнутри события исходящих RPC и пакетов. Исправления для этого бага нет, но есть способ не провоцировать его. Вызов sampSendChat изнутри обработчика исходящих RPC/пакетов нужно обернуть в скриптовый поток с нулевой задержкой:
Lua:
function onSendRpc(id)
  -- крашит:
  -- sampSendChat('Send RPC: ' .. id)

  -- норм:
  lua_thread.create(function()
    wait(0)
    sampSendChat('Send RPC: ' .. id)
  end)
end
 
Последнее редактирование:
У

Удалённый пользователь 341712

Гость
Пример
Lua:
[CODE=lua]local HLcfg = inicfg.load({
    config = {
        name = '',
        Family = ''
    }
}, 'test.ini')

inicfg.save(HLcfg, 'test.ini')

local name = imgui.ImBuffer(tostring(HLcfg.config.name), 256)

local Family = imgui.ImBuffer(tostring(HLcfg.config.Family), 256)

-- imgui

imgui.Text(u8'введите ник') imgui.SameLine() imgui.PushItemWidth(250) if imgui.InputText(u8'##1', name) then
    HLcfg.config.nick = nick.v
    save()
end imgui.PopItemWidth()

imgui.Text(u8'введите фамилию') imgui.SameLine() imgui.PushItemWidth(250) if imgui.InputText(u8'##2', Family) then
    HLcfg.config.Family = Family.v
    save()
end

if imgui.Button(u8'Вывести', imgui.ImVec2(150, 0)) then
    sampSendChat('name: '..name.v..' family: '..Family.v)
end

-- любое место кода

function save()
    inicfg.save(HLcfg, 'test.ini')
end
 
  • Нравится
Реакции: HpP

Di3

Участник
432
20
Кто подскажет как через sync отправить серверу нажатие клавиши N
 

HpP

Известный
368
117
Что делать если, во время закрытия окна ImGui на крестик, выскакивает такая ошибка?(Если закрыть с помощью команды, её не будет).
 

Вложения

  • Bruh....png
    Bruh....png
    7.3 KB · Просмотры: 78

HpP

Известный
368
117

Lua:
script_name('Helper For AutoSchool')
script_author('HpP')
script_version('0.0.8')

require "lib.moonloader"
local encoding = require "encoding"
local inicfg = require "inicfg"
local sampev = require "lib.samp.events"
local imgui = require "imgui"
local key = require 'vkeys'
local fa = require 'fAwesome5'
imgui.ToggleButton = require('imgui_addons').ToggleButton
encoding.default = 'CP1251'
u8 = encoding.UTF8

--local pie = require 'imgui_piemenu'

local AutoWindow = imgui.ImBool(false)

local name = imgui.ImBuffer(256)
local surname = imgui.ImBuffer(256)

local memberjob = imgui.ImBuffer(256)

local sw, sh = getScreenResolution()

local combo = imgui.ImInt(0)
local list = {
    u8'Мужчина',
    u8'Женщина'
}

local cfg = inicfg.load(config, 'School-Helper.ini')
if not doesFileExist('moonloader/config/School-Helper.ini') then inicfg.save(config, 'School-Helper.ini') end

local config = {
    config = {
name = '',
surname = '',
memberjob = '',
    },
}


function cmd_auto(arg)
    AutoWindow.v = not AutoWindow.v
    imgui.Process = AutoWindow.v
end

function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(100) end
    
    sampRegisterChatCommand('auto', cmd_auto)
    sampAddChatMessage('{e85d13}[Helper For AutoSchool]{FFFFFF} Скрипт успешно загружен | Автор: {e85d13}HpP', 0xFFFFFF) -- Выводим в чат сообщение
    sampAddChatMessage('{e85d13}[Helper For AutoSchool]{FFFFFF} Чтобы открыть настройки скрипта, используйте команду - {e85d13}/auto', 0xFFFFFF)

    while true do
        wait(0)
   end
end

function apply_custom_style()
 imgui.SwitchContext()
 local style = imgui.GetStyle()
 local colors = style.Colors
 local clr = imgui.Col
 local ImVec4 = imgui.ImVec4
 style.WindowRounding = 2.0
 style.WindowTitleAlign = imgui.ImVec2(0.5, 0.84)
 style.ChildWindowRounding = 2.0
 style.FrameRounding = 2.0
 style.ItemSpacing = imgui.ImVec2(5.0, 4.0)
 style.ScrollbarSize = 13.0
 style.ScrollbarRounding = 0
 style.GrabMinSize = 8.0
 style.GrabRounding = 1.0
    colors[clr.FrameBg] = ImVec4(0.48, 0.16, 0.16, 0.54)
    colors[clr.FrameBgHovered] = ImVec4(0.98, 0.26, 0.26, 0.40)
    colors[clr.FrameBgActive] = ImVec4(0.98, 0.26, 0.26, 0.67)
    colors[clr.TitleBg] = ImVec4(0.04, 0.04, 0.04, 1.00)
    colors[clr.TitleBgActive] = ImVec4(0.48, 0.16, 0.16, 1.00)
    colors[clr.TitleBgCollapsed] = ImVec4(0.00, 0.00, 0.00, 0.51)
    colors[clr.CheckMark] = ImVec4(0.98, 0.26, 0.26, 1.00)
    colors[clr.SliderGrab] = ImVec4(0.88, 0.26, 0.24, 1.00)
    colors[clr.SliderGrabActive] = ImVec4(0.98, 0.26, 0.26, 1.00)
    colors[clr.Button] = ImVec4(0.00, 0.00, 0.00, 0.00)
    colors[clr.ButtonHovered] = ImVec4(0.75, 0.16, 0.16, 0.54)
    colors[clr.ButtonActive] = ImVec4(0.75, 0.16, 0.16, 0.54)
    colors[clr.Header] = ImVec4(0.98, 0.26, 0.26, 0.31)
    colors[clr.HeaderHovered] = ImVec4(0.98, 0.26, 0.26, 0.80)
    colors[clr.HeaderActive] = ImVec4(0.98, 0.26, 0.26, 1.00)
    colors[clr.Separator] = colors[clr.Border]
    colors[clr.SeparatorHovered] = ImVec4(0.75, 0.10, 0.10, 0.78)
    colors[clr.SeparatorActive] = ImVec4(0.75, 0.10, 0.10, 1.00)
    colors[clr.ResizeGrip] = ImVec4(0.98, 0.26, 0.26, 0.25)
    colors[clr.ResizeGripHovered] = ImVec4(0.98, 0.26, 0.26, 0.67)
    colors[clr.ResizeGripActive] = ImVec4(0.98, 0.26, 0.26, 0.95)
    colors[clr.TextSelectedBg] = ImVec4(0.98, 0.26, 0.26, 0.35)
    colors[clr.Text] = ImVec4(1.00, 1.00, 1.00, 1.00)
    colors[clr.TextDisabled] = ImVec4(0.50, 0.50, 0.50, 1.00)
    colors[clr.WindowBg] = ImVec4(0.06, 0.06, 0.06, 0.94)
    colors[clr.ChildWindowBg] = ImVec4(1.00, 1.00, 1.00, 0.00)
    colors[clr.PopupBg] = ImVec4(0.08, 0.08, 0.08, 0.94)
    colors[clr.ComboBg] = colors[clr.PopupBg]
    colors[clr.Border] = ImVec4(0.43, 0.43, 0.50, 0.50)
    colors[clr.BorderShadow] = ImVec4(0.00, 0.00, 0.00, 0.00)
    colors[clr.MenuBarBg] = ImVec4(0.14, 0.14, 0.14, 1.00)
    colors[clr.ScrollbarBg] = ImVec4(0.02, 0.02, 0.02, 0.53)
    colors[clr.ScrollbarGrab] = ImVec4(0.31, 0.31, 0.31, 1.00)
    colors[clr.ScrollbarGrabHovered] = ImVec4(0.41, 0.41, 0.41, 1.00)
    colors[clr.ScrollbarGrabActive] = ImVec4(0.51, 0.51, 0.51, 1.00)
    colors[clr.CloseButton] = ImVec4(0.41, 0.41, 0.41, 0.50)
    colors[clr.CloseButtonHovered] = ImVec4(0.98, 0.39, 0.36, 1.00)
    colors[clr.CloseButtonActive] = ImVec4(0.98, 0.39, 0.36, 1.00)
    colors[clr.PlotLines] = ImVec4(0.61, 0.61, 0.61, 1.00)
    colors[clr.PlotLinesHovered] = ImVec4(1.00, 0.43, 0.35, 1.00)
    colors[clr.PlotHistogram] = ImVec4(0.90, 0.70, 0.00, 1.00)
    colors[clr.PlotHistogramHovered] = ImVec4(1.00, 0.60, 0.00, 1.00)
    colors[clr.ModalWindowDarkening] = ImVec4(0.80, 0.80, 0.80, 0.35)
end
apply_custom_style()

function imgui.OnDrawFrame()

   if not AutoWindow.v then
        imgui.Process = false
   end
   
if AutoWindow.v then
    imgui.SetNextWindowSize(imgui.ImVec2(930, 500), imgui.Cond.FirstUseEver) -- Размер окна Imgui.
    imgui.SetNextWindowPos(imgui.ImVec2(sw / 1.9, sh / 1.52), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5)) -- Позиция ImGui при открывании.
    imgui.Begin(u8'[Helper For AutoSchool] Версия скрипта '..thisScript().version, AutoWindow, imgui.WindowFlags.NoResize)
    imgui.BeginChild("child", imgui.ImVec2(170, 463), true)
    imgui.Text(u8'      Функции')
    imgui.Separator()
    imgui.Separator()
 if imgui.Button(u8'Основные настройки', imgui.ImVec2(-1, 20)) then menu = 1 end
 if    imgui.Button(u8'Настройки лекций', imgui.ImVec2(-1, 20)) then menu = 2 end
 if    imgui.Button(u8'Основные команды', imgui.ImVec2(-1, 20)) then menu = 3 end
 if    imgui.Button(u8'О Авторе/Скрипте', imgui.ImVec2(-1, 20)) then menu = 4 end
    imgui.EndChild()
    imgui.SameLine()
 if menu == 1 then
    imgui.BeginChild('Основные настройки', imgui.ImVec2(738, 463), true)
    imgui.Text(u8'Введите имя персонажа:')
    imgui.PushItemWidth(200) -- Изменяет длину imgui.InputText.
    imgui.InputText(u8'#0', name)
 if imgui.IsItemHovered() then
    imgui.BeginTooltip()
    imgui.TextUnformatted(u8('Внимание!\nПросьба не сохранять пустые поля\nИначе в config, тоже будут пустые поля.\nА это - не хорошо!'))
    imgui.EndTooltip()
end
    imgui.PopItemWidth()
    imgui.Text(' ')
    imgui.Text(u8'Введите фамилию персонажа: ')
    imgui.PushItemWidth(200)
    imgui.InputText(u8'#1', surname)
 if imgui.IsItemHovered() then
    imgui.BeginTooltip()
    imgui.TextUnformatted(u8('Внимание!\nПросьба не сохранять пустые поля\nИначе в config, тоже будут пустые поля.\nА это - не хорошо!'))
    imgui.EndTooltip()
end
    imgui.Text(' ')
    imgui.Text(u8'Введите должность:')
    imgui.PushItemWidth(200)
    imgui.InputText(u8'#2', memberjob)
 if imgui.IsItemHovered() then
    imgui.BeginTooltip()
    imgui.TextUnformatted(u8('Внимание!\nПросьба не сохранять пустые поля\nИначе в config, тоже будут пустые поля.\nА это - не хорошо!'))
    imgui.EndTooltip()
end
    imgui.PopItemWidth()
    imgui.Text(' ')
    imgui.Text(u8'Пол Вашего персонажа: ')
    imgui.PushItemWidth(200)
    imgui.Combo(' ', combo, list) -- Выбор для пола персонажа.
    imgui.PushItemWidth(200)
    imgui.Text(' ')
 if imgui.Button(u8'Сохранить настройки', imgui.ImVec2(-1, 20)) then
        config.config.name = name.v   -- Сохранение информации в конфиг.
        config.config.surname = surname.v
        config.config.memberjob = memberjob.v
        config.config.combo = combo.v
        inicfg.save(config, 'School-Helper.ini')
    sampAddChatMessage('{e85d13}[School-Helper] {FFFFFF}Ваши настройки, были {e85d13}сохранены', -1)
end
    imgui.Separator()
    imgui.Text(u8'                                                                             Примеры Ваших отыгровок: ')
    imgui.Text(u8'/do На груди висит бейджик с надписью:"'..memberjob.v..', '..name.v..' '..surname.v..'"')
    imgui.Text(u8'Здравствуйте, могу ли я, Вам чем-нибудь помочь?')
    imgui.EndChild()
end
end
    imgui.SameLine() -- Остается на той же строке.
 if menu == 2 then
    imgui.BeginChild('Настройки лекций', imgui.ImVec2(738, 463), true)
    imgui.Text(u8' ')
    imgui.EndChild()
end
    imgui.SameLine()
 if menu == 3 then
    imgui.BeginChild('Основные команды', imgui.ImVec2(738, 463), true)
    imgui.Text(u8' ')
    imgui.EndChild()
end
imgui.SameLine()
  if menu == 4 then
    imgui.BeginChild('О Авторе/Скрипте', imgui.ImVec2(738, 463), true)
    imgui.Text(u8' ')
    imgui.EndChild()
end
    imgui.End()
end
 

CaJlaT

Овощ
Модератор
2,805
2,606
Сорян, что так долго.... может глюить из-за русских символов (на видео видно)

Lua:
local imgui = require 'imgui'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
local window = imgui.ImBool(false)
local find = imgui.ImBuffer(u8'', 256)
local text = [[
    Привет
    Строка #2
    Ещё одна строка
    Строчка 4
    blast.hk
    lua
    Последняя строка
]]
function main()
    if not isSampLoaded() and not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    sampRegisterChatCommand('imgui', function() window.v = not window.v end)
    while true do
        wait(0)
        imgui.Process = window.v
    end
end
function imgui.OnDrawFrame()
    imgui.Begin('Test Find', window)
        imgui.PushItemWidth(200)
        imgui.InputText(u8'Поиск по тексту', find)
        imgui.PopItemWidth()
        imgui.Separator()
        for i in text:gmatch("[^\r\n]+") do
            if find.v ~= '' then
                if string.rlower(i):find(string.lower(u8:decode(find.v))) then
                    imgui.TextColoredRGB(i:gsub(string.lower(u8:decode(find.v)), '{FFFF00}'..string.lower(u8:decode(find.v))..'{SSSSSS}'))
                end
            else
                imgui.TextColoredRGB(i)
            end
        end
    imgui.End()
end
function imgui.TextColoredRGB(text)
    local style = imgui.GetStyle()
    local colors = style.Colors
    local ImVec4 = imgui.ImVec4
    local explode_argb = function(argb)
        local a = bit.band(bit.rshift(argb, 24), 0xFF)
        local r = bit.band(bit.rshift(argb, 16), 0xFF)
        local g = bit.band(bit.rshift(argb, 8), 0xFF)
        local b = bit.band(argb, 0xFF)
        return a, r, g, b
    end
    local getcolor = function(color)
        if color:sub(1, 6):upper() == 'SSSSSS' then
            local r, g, b = colors[1].x, colors[1].y, colors[1].z
            local a = tonumber(color:sub(7, 8), 16) or colors[1].w * 255
            return ImVec4(r, g, b, a / 255)
        end
        local color = type(color) == 'string' and tonumber(color, 16) or color
        if type(color) ~= 'number' then return end
            local r, g, b, a = explode_argb(color)
        return imgui.ImColor(r, g, b, a):GetVec4()
    end
    local render_text = function(text_)
        for w in text_:gmatch('[^\r\n]+') do
            local text, colors_, m = {}, {}, 1
            w = w:gsub('{(......)}', '{%1FF}')
            while w:find('{........}') do
                local n, k = w:find('{........}')
                local color = getcolor(w:sub(n + 1, k - 1))
                if color then
                    text[#text], text[#text + 1] = w:sub(m, n - 1), w:sub(k + 1, #w)
                    colors_[#colors_ + 1] = color
                    m = n
                end
                w = w:sub(1, n - 1) .. w:sub(k + 1, #w)
            end
            if text[0] then
                for i = 0, #text do
                    imgui.TextColored(colors_[i] or colors[1], u8(text[i]))
                    imgui.SameLine(nil, 0)
                end
                imgui.NewLine()
            else imgui.Text(u8(w)) end
        end
    end
    render_text(text)
end
local russian_characters = {
    [168] = 'Ё', [184] = 'ё', [192] = 'А', [193] = 'Б', [194] = 'В', [195] = 'Г', [196] = 'Д', [197] = 'Е', [198] = 'Ж', [199] = 'З', [200] = 'И', [201] = 'Й', [202] = 'К', [203] = 'Л', [204] = 'М', [205] = 'Н', [206] = 'О', [207] = 'П', [208] = 'Р', [209] = 'С', [210] = 'Т', [211] = 'У', [212] = 'Ф', [213] = 'Х', [214] = 'Ц', [215] = 'Ч', [216] = 'Ш', [217] = 'Щ', [218] = 'Ъ', [219] = 'Ы', [220] = 'Ь', [221] = 'Э', [222] = 'Ю', [223] = 'Я', [224] = 'а', [225] = 'б', [226] = 'в', [227] = 'г', [228] = 'д', [229] = 'е', [230] = 'ж', [231] = 'з', [232] = 'и', [233] = 'й', [234] = 'к', [235] = 'л', [236] = 'м', [237] = 'н', [238] = 'о', [239] = 'п', [240] = 'р', [241] = 'с', [242] = 'т', [243] = 'у', [244] = 'ф', [245] = 'х', [246] = 'ц', [247] = 'ч', [248] = 'ш', [249] = 'щ', [250] = 'ъ', [251] = 'ы', [252] = 'ь', [253] = 'э', [254] = 'ю', [255] = 'я',
}
function string.rlower(s)
    s = s:lower()
    local strlen = s:len()
    if strlen == 0 then return s end
    s = s:lower()
    local output = ''
    for i = 1, strlen do
        local ch = s:byte(i)
        if ch >= 192 and ch <= 223 then -- upper russian characters
            output = output .. russian_characters[ch + 32]
        elseif ch == 168 then -- Ё
            output = output .. russian_characters[184]
        else
            output = output .. string.char(ch)
        end
    end
    return output
end
 

Вложения

  • zdarova.lua
    3.9 KB · Просмотры: 6

sep

Известный
672
76
как вместо ид ввести надпись на тексдайве
di-4OTTG5[1].png

sampSendClickTextdraw(1481)
как не показывая окно↓↓↓ кликнув по тексдрайву

di-VELVUX[1].png


почему фото ссылкой вставить незя а картинкой можно
di-HJO1KI[1].png
 
Последнее редактирование:

Felix...

Потрачен
3
0
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
как сделать в боте который должен работать в фоне правильное нажатие клавиш?
setVirtualKeyDown работает пиздец как криво
 

staffed

Новичок
9
0
поможет кто скрипт с SetVirtualKeyDown переделать на setGameKeyState в setGameKeyState шарю просто ВОТ скрипт:
script_name("AutoBot") -- Тут наш любимый скрипт инфо :)
script_version_number(1)
script_version("0.1")
script_authors("StaFF")

require "lib.moonloader"
local ev = require("lib.samp.events")
local keys = require "vkeys"



function main()
if not isSampfuncsLoaded() or not isSampLoaded() then return end

sampRegisterChatCommand("at", cmd_at)

while true do
wait(0)
if active then
setVirtualKeyDown(VK_RETURN, true)
wait(100)
setVirtualKeyDown(VK_RETURN, false)
wait(2000)
setVirtualKeyDown(VK_MENU, true)
wait(100)
setVirtualKeyDown(VK_MENU, false)
wait(2000)
setVirtualKeyDown(VK_RETURN, true)
wait(100)
setVirtualKeyDown(VK_RETURN, false)
wait(3000)
setVirtualKeyDown(VK_D, true)
wait(200)
setVirtualKeyDown(VK_D, false)
wait(50)
sampProcessChatInput('/fillcar')
wait(50)
setVirtualKeyDown(VK_S, true)
wait(200)
setVirtualKeyDown(VK_S, false)
wait(50)
sampProcessChatInput('/fillcar')
wait(50)
setVirtualKeyDown(VK_D, true)
wait(200)
setVirtualKeyDown(VK_D, false)
wait(50)
sampProcessChatInput('/fillcar')
wait(50)
setVirtualKeyDown(VK_S, true)
wait(200)
setVirtualKeyDown(VK_S, false)
wait(50)
sampProcessChatInput('/fillcar')
wait(50)
setVirtualKeyDown(VK_D, true)
wait(200)
setVirtualKeyDown(VK_D, false)
wait(50)
sampProcessChatInput('/fillcar')
wait(50)
setVirtualKeyDown(VK_S, true)
wait(200)
setVirtualKeyDown(VK_S, false)
wait(50)
sampProcessChatInput('/fillcar')
wait(50)
setVirtualKeyDown(VK_D, true)
wait(200)
setVirtualKeyDown(VK_D, false)
wait(50)
sampProcessChatInput('/fillcar')
wait(50)
setVirtualKeyDown(VK_S, true)
wait(200)
setVirtualKeyDown(VK_S, false)
wait(50)
sampProcessChatInput('/fillcar')
wait(1500)
setVirtualKeyDown(VK_G, true)
wait(90)
setVirtualKeyDown(VK_G, false)
wait(80)
setVirtualKeyDown(VK_G, true)
wait(70)
setVirtualKeyDown(VK_G, false)
wait(60)
setVirtualKeyDown(VK_G, true)
wait(50)
setVirtualKeyDown(VK_G, false)
wait(40)
setVirtualKeyDown(VK_G, true)
wait(30)
setVirtualKeyDown(VK_G, false)
wait(20)
setVirtualKeyDown(VK_G, true)
wait(10)
setVirtualKeyDown(VK_G, false)
wait(5000)
setVirtualKeyDown(VK_Down, true)
wait(200)
setVirtualKeyDown(VK_Down, false)
wait(200)
setVirtualKeyDown(VK_RETURN, true)
wait(50)
setVirtualKeyDown(VK_RETURN, false)
wait(63000)
setVirtualKeyDown(VK_Control, true)
wait(1000)
setVirtualKeyDown(VK_F, true)
wait(500)
setVirtualKeyDown(VK_F, false)
wait(500)
setVirtualKeyDown(VK_Control, false)
wait(500)
sampProcessChatInput('/rec 15')
sampAddChatMessage('Скрипт выключен, для повторной активации введите {ff0000}/at', -1)
wait(25000)
end
end
end

function cmd_at(penis)
active = not active
sampAddChatMessage(active and 'Активировано' or 'Деактивировано', -1)
end