Вопросы по 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
 
Последнее редактирование:

Fomikus

Известный
Проверенный
474
343
тогда или перезагрузка скрипта или перед каждым выводом в чат нужно проверять какую-нибудь переменную, которая будет отвечать за выполнение лекций
Почему отваливается бот после 1 шага?
Lua:
function main()
    if not isSampLoaded() and not isSampfuncsLoaded then return end
    while not isSampAvailable() do wait(0) end
    sampRegisterChatCommand('MyBot', BotCode)
    wait(-1)
end

function BotCode()
    lua_thread.create(function ()
        BeginToPoint(1481.174560, -1349.359985, 113.129318, 1.000000, -255, true)
                wait(1000)
        if sampIsDialogActive() then
            local id = sampGetCurrentDialogId()
            if id == 857 then
        sampSendDialogResponse(857, 1, 1, -1)
                wait(1000)
        end
        end
        BeginToPoint(1474.552246, -1349.468627, 113.13032531738, 1.000000, -255, false)
            end)
end
Если добавить строчку:
sampAddChatMessage(1, -1)
После 1 строки потока,
Он сделает шаг, напишет 1
 

3loe_ny3uko

Новичок
10
0
Как рандомизировать текст? К примеру, я хочу сделать скрипт, который будут использовать много людей, и при отыгровке армейского жетона у всех выдавал разный номер. То-есть к примеру:

/do |=== National Guard San Andreas ===|
/do |=== Номер жетона: 256721 ===|
/do |=== Имя Фамилия бойца: Soap_Mctavish ===|
/do |=== Подразделение: ВМФ|А ===|
Я хочу сделать что бы у каждого игрока номер жетона был рандомным шестизначным числом. Как такое сделать?
 

3loe_ny3uko

Новичок
10
0
Крашит скрипт после выполнения этой команды.

Lua:
function showtagc()
            local num = math.random(100000, 999999)
            local result, playerID = sampGetPlayerIdByCharHandle(playerPed)
          if result then
          namelol = sampGetPlayerNickname(playerID)
          local namel, familyl = string.match(namelol, '(%a+)_(%a+)')
            showtagc = string.match(param, '(%d+)')
            lua_thread.create(function()
              sampProcessCharInput("/me достал из под кителя жетон на цепочке и показал его")
              wait(1500)
              sampProcessCharInput("/do |=== National Guard San Andreas ===|")
              wait(2500)
              sampProcessCharInput("/do |=== №жетона: "..num.." ===|")
              wait(2500)
              sampProcessCharInput("/do |=== Имя Фамилия: "..namelol.." ===| ")
              wait(2500)
              sampProcessCharInput("/do /do |=== Подразделение: ВМФ|C ===| ")
              end)
            end
          end
 

checkdasound

Известный
Проверенный
963
407
[ML] (error) AutoBicycleSwimRunOnMaxSpeed_space: opcode '00DD' call caused an unhandled exception
stack traceback:
[C]: in function 'isCharInModel'
D:\Games\GTA San Andreas\moonloader\space_maxspeed.lua:7: in main chunk
[ML] (error) AutoBicycleSwimRunOnMaxSpeed_space: Script died due to an error. (074FA684)

После запуска игры такая ошибка, но если перезагрузить все скрипты при помощи reload_all, то скрипт успешно загружается, что делать.
Код ниже.
Lua:
script_name("AutoBicycleSwimRunOnMaxSpeed_space")
script_author("checkdasound")


local isCharOnBicycle =
{
    [1] = isCharInModel(playerPed, 481),
    [2] = isCharInModel(playerPed, 509),
    [3] = isCharInModel(playerPed, 510)
}

function main()
    while true do
    wait(0)
        if isCharOnBicycle and isCharInAnyCar(playerPed) and isKeyCheckAvailable() and isKeyDown(0xA0) then    -- onBicycle SpeedUP [[LSHIFT]] --
            setVirtualKeyDown(0x57, true)
            wait(20)
            setVirtualKeyDown(0x57, false)
        end
        if isCharOnFoot(playerPed) and isKeyDown(0x14) and isKeyCheckAvailable() then -- onFoot SpeedUP [[CAPSLOCK]] --
            setVirtualKeyDown(0x20, true)
            wait(10)
            setVirtualKeyDown(0x20, false)
        end
        if isCharInWater(playerPed) and isKeyDown(0x14) and isKeyCheckAvailable() then -- inWater SpeedUP [[CAPSLOCK]] --
            setVirtualKeyDown(0x20, true)
            wait(10)
            setVirtualKeyDown(0x20, false)
        end
    end
end

function isKeyCheckAvailable()
    if not isSampLoaded() then
        return true
    end
    if not isSampfuncsLoaded() then
        return not sampIsChatInputActive() and not sampIsDialogActive()
    end
    return not sampIsChatInputActive() and not sampIsDialogActive() and not isSampfuncsConsoleActive()
end
 

#Northn

Pears Project — уже запущен!
Всефорумный модератор
2,643
2,493
[ML] (error) AutoBicycleSwimRunOnMaxSpeed_space: opcode '00DD' call caused an unhandled exception
stack traceback:
[C]: in function 'isCharInModel'
D:\Games\GTA San Andreas\moonloader\space_maxspeed.lua:7: in main chunk
[ML] (error) AutoBicycleSwimRunOnMaxSpeed_space: Script died due to an error. (074FA684)

После запуска игры такая ошибка, но если перезагрузить все скрипты при помощи reload_all, то скрипт успешно загружается, что делать.
Код ниже.
Lua:
script_name("AutoBicycleSwimRunOnMaxSpeed_space")
script_author("checkdasound")


local isCharOnBicycle =
{
    [1] = isCharInModel(playerPed, 481),
    [2] = isCharInModel(playerPed, 509),
    [3] = isCharInModel(playerPed, 510)
}

function main()
    while true do
    wait(0)
        if isCharOnBicycle and isCharInAnyCar(playerPed) and isKeyCheckAvailable() and isKeyDown(0xA0) then    -- onBicycle SpeedUP [[LSHIFT]] --
            setVirtualKeyDown(0x57, true)
            wait(20)
            setVirtualKeyDown(0x57, false)
        end
        if isCharOnFoot(playerPed) and isKeyDown(0x14) and isKeyCheckAvailable() then -- onFoot SpeedUP [[CAPSLOCK]] --
            setVirtualKeyDown(0x20, true)
            wait(10)
            setVirtualKeyDown(0x20, false)
        end
        if isCharInWater(playerPed) and isKeyDown(0x14) and isKeyCheckAvailable() then -- inWater SpeedUP [[CAPSLOCK]] --
            setVirtualKeyDown(0x20, true)
            wait(10)
            setVirtualKeyDown(0x20, false)
        end
    end
end

function isKeyCheckAvailable()
    if not isSampLoaded() then
        return true
    end
    if not isSampfuncsLoaded() then
        return not sampIsChatInputActive() and not sampIsDialogActive()
    end
    return not sampIsChatInputActive() and not sampIsDialogActive() and not isSampfuncsConsoleActive()
end

В самое начало функции main(), ПЕРЕД бесконечным циклом:
Lua:
while not isSampAvailable() do wait(1000) end
 

checkdasound

Известный
Проверенный
963
407
добавь в начале мейна проверку на загруженность сампа и сфа
Lua:
if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
В самое начало функции main(), ПЕРЕД бесконечным циклом:
Lua:
while not isSampAvailable() do wait(1000) end
Не помогает, та же самая ошибка, я уже пробовал так.
Ну раз ошибка с isCharInModel, то я воспользуюсь альтернативным методом: Вопросы по Lua скриптингу(https://blast.hk/threads/13892/page-235#post-213562)
 
Последнее редактирование:

3loe_ny3uko

Новичок
10
0
нет такой функи sampProcessCharInput, есть sampProcessChatInput. Да и тут я бы юзал sampSendChat
Беда в том, что и sampSendChat тоже крашит скрипт. Лог пишет, что беда в этой строчке: showtagc = string.match(param, '(%d+)')
Скрипт называется NAVY, лог прикрепил ниже

[22:04:29.312622] (system) Session started.
[22:04:29.313622] (debug) Module handle: 74420000

MoonLoader v.025-beta loaded.
Developers: FYP, hnnssy, EvgeN 1137

Copyright (c) 2016, BlastHack Team
Избранное - Lua - ASI - MoonLoader(https://www.blast.hk/moonloader/)

[22:04:29.313622] (info) Working directory: D:\GTA San Andreas\moonloader
[22:04:29.313622] (debug) FP Control: 0009001F
[22:04:29.313622] (debug) Game: GTA SA 1.0.0.0 US
[22:04:29.313622] (system) Installing pre-game hooks...
[22:04:29.313622] (system) Hooks installed.
[22:04:29.862653] (debug) Initializing opcode handler table
[22:04:29.862653] (debug) package.path = D:\GTA San Andreas\moonloader\lib\?.lua;D:\GTA San Andreas\moonloader\lib\?\init.lua;D:\GTA San Andreas\moonloader\?.lua;D:\GTA San Andreas\moonloader\?\init.lua;.\?.lua;D:\GTA San Andreas\moonloader\lib\?.luac;D:\GTA San Andreas\moonloader\lib\?\init.luac;D:\GTA San Andreas\moonloader\?.luac;D:\GTA San Andreas\moonloader\?\init.luac;.\?.luac
[22:04:29.862653] (debug) package.cpath = D:\GTA San Andreas\moonloader\lib\?.dll;
[22:04:29.862653] (system) Loading script 'D:\GTA San Andreas\moonloader\33_pisser_7 (1).lua'...
[22:04:29.862653] (debug) New script: 01CB89EC
[22:04:29.866654] (system) pisser: Loaded successfully.
[22:04:29.866654] (system) Loading script 'D:\GTA San Andreas\moonloader\AutoReboot.lua'...
[22:04:29.866654] (debug) New script: 06B5CB04
[22:04:29.867654] (system) ML-AutoReboot: Loaded successfully.
[22:04:29.867654] (system) Loading script 'D:\GTA San Andreas\moonloader\imgui test.lua'...
[22:04:29.867654] (debug) New script: 06B5E324
[22:04:29.875654] (system) KonohaUpdater: Loaded successfully.
[22:04:29.875654] (system) Loading script 'D:\GTA San Andreas\moonloader\KonohaUpdater.lua'...
[22:04:29.875654] (debug) New script: 01BBA84C
[22:04:29.877654] (system) KonohaUpdater: Loaded successfully.
[22:04:29.877654] (system) Loading script 'D:\GTA San Andreas\moonloader\NAVY.lua'...
[22:04:29.877654] (debug) New script: 06B630EC
[22:04:29.880654] (system) NAVY: Loaded successfully.
[22:04:29.880654] (system) Loading script 'D:\GTA San Andreas\moonloader\PHelper.lua'...
[22:04:29.880654] (debug) New script: 06B63294
[22:04:29.882654] (system) updatedPHelper: Loaded successfully.
[22:04:29.882654] (system) Loading script 'D:\GTA San Andreas\moonloader\reload_all.lua'...
[22:04:29.882654] (debug) New script: 06B74ABC
[22:04:29.883655] (system) ML-ReloadAll: Loaded successfully.
[22:04:29.883655] (system) Loading script 'D:\GTA San Andreas\moonloader\sekta.lua'...
[22:04:29.883655] (debug) New script: 06B77E04
[22:04:29.885655] (system) sekta: Loaded successfully.
[22:04:29.885655] (system) Loading script 'D:\GTA San Andreas\moonloader\SF Integration.lua'...
[22:04:29.885655] (debug) New script: 06B77FAC
[22:04:29.888655] (system) SF Integration: Loaded successfully.
[22:04:29.888655] (system) Loading script 'D:\GTA San Andreas\moonloader\SWATupdater.lua'...
[22:04:29.888655] (debug) New script: 06B78554
[22:04:29.890655] (system) SWATupdater: Loaded successfully.
[22:04:40.943287] (system) Installing post-load hooks...
[22:04:40.943287] (system) Hooks installed.
[22:04:40.944287] (debug) Add thread 01CDA67D to SCM-thread queue
[22:04:42.388370] (script) pisser: pisser can't establish connection to rubbishman.ru
[22:04:42.448373] (debug) Add thread 06A083E5 to SCM-thread queue
[22:04:42.840396] (debug) Add thread 06A0850D to SCM-thread queue
[22:04:42.840396] (debug) Add thread 06A08635 to SCM-thread queue
[22:04:42.840396] (debug) Add thread 06A0875D to SCM-thread queue
[22:04:42.841396] (debug) Add thread 06A08885 to SCM-thread queue
[22:04:43.251419] (debug) Add thread 06A089AD to SCM-thread queue
[22:04:43.251419] (script) updatedPHelper: [PHELP] Update starts.
[22:04:43.959460] (script) updatedPHelper: [PHELP] Update successful.
[22:04:44.109468] (script) updatedPHelper: [PHELP] 1st config updated successful.
[22:04:44.109468] (script) updatedPHelper: [PHELP] 2nd config updated successful.
[22:04:45.242533] (system) Loading script 'C:\Users\tarakan2.0\AppData\Local\Temp\PHelperTEST.lua'...
[22:04:45.242533] (debug) New script: 0A02B0EC
[22:04:45.249533] (debug) Add thread 09FFB16D to SCM-thread queue
[22:04:45.256534] (system) PHelper: Loaded successfully.
[22:04:45.257534] (debug) Add thread 06A08BFD to SCM-thread queue
[22:04:47.560666] (system) Loading script 'C:\Users\tarakan2.0\AppData\Local\Temp\imgui_simple_scoreboard.lua'...
[22:04:47.560666] (debug) New script: 0A03B42C
[22:04:47.566666] (system) ImGui Scoreboard: Loaded successfully.
[22:04:48.111697] (system) Loading script 'C:\Users\tarakan2.0\AppData\Local\Temp\newMENU.lua'...
[22:04:48.111697] (debug) New script: 0A2FCF34
[22:04:48.117697] (system) PHelpFMENU: Loaded successfully.
[22:04:48.657728] (system) Loading script 'C:\Users\tarakan2.0\AppData\Local\Temp\newSpotlight.lua'...
[22:04:48.657728] (debug) New script: 0A001A04
[22:04:48.661729] (system) newSpotlight: Loaded successfully.
[22:05:09.300909] (error) NAVY: D:\GTA San Andreas\moonloader\NAVY.lua:167: bad argument #1 to 'match' (string expected, got nil)
stack traceback:
[C]: in function 'match'
D:\GTA San Andreas\moonloader\NAVY.lua:167: in function <D:\GTA San Andreas\moonloader\NAVY.lua:161>
[22:05:09.307909] (error) NAVY: Script died due to error. (06B630EC)
[22:05:09.307909] (debug) Remove thread 06A08635 from SCM-thread queue
[22:05:12.818110] (system) pisser: Script terminated. (01CB89EC)
[22:05:12.818110] (debug) Remove thread 06A083E5 from SCM-thread queue
[22:05:12.818110] (system) ML-AutoReboot: Script terminated. (06B5CB04)
[22:05:12.819110] (system) KonohaUpdater: Script terminated. (06B5E324)
[22:05:12.819110] (system) KonohaUpdater: Script terminated. (01BBA84C)
[22:05:12.819110] (debug) Remove thread 06A0850D from SCM-thread queue
[22:05:12.820110] (system) updatedPHelper: Script terminated. (06B63294)
[22:05:12.820110] (debug) Remove thread 06A089AD from SCM-thread queue
[22:05:12.820110] (system) ML-ReloadAll: Script terminated. (06B74ABC)
[22:05:12.820110] (system) sekta: Script terminated. (06B77E04)
[22:05:12.820110] (debug) Remove thread 06A0875D from SCM-thread queue
[22:05:12.821110] (system) SF Integration: Script terminated. (06B77FAC)
[22:05:12.821110] (debug) Remove thread 01CDA67D from SCM-thread queue
[22:05:12.821110] (system) SWATupdater: Script terminated. (06B78554)
[22:05:12.821110] (debug) Remove thread 06A08885 from SCM-thread queue
[22:05:12.821110] (system) PHelper: Script terminated. (0A02B0EC)
[22:05:12.821110] (debug) Remove thread 06A08BFD from SCM-thread queue
[22:05:12.823111] (system) ImGui Scoreboard: Script terminated. (0A03B42C)
[22:05:12.824111] (system) PHelpFMENU: Script terminated. (0A2FCF34)
[22:05:12.825111] (system) newSpotlight: Script terminated. (0A001A04)
[22:05:12.825111] (system) Loading script 'D:\GTA San Andreas\moonloader\33_pisser_7 (1).lua'...
[22:05:12.825111] (debug) New script: 0A02B0EC
[22:05:12.828111] (system) pisser: Loaded successfully.
[22:05:12.828111] (system) Loading script 'D:\GTA San Andreas\moonloader\AutoReboot.lua'...
[22:05:12.828111] (debug) New script: 1ED7BFEC
[22:05:12.830111] (system) ML-AutoReboot: Loaded successfully.
[22:05:12.830111] (system) Loading script 'D:\GTA San Andreas\moonloader\imgui test.lua'...
[22:05:12.830111] (debug) New script: 1ED7C194
[22:05:12.836111] (system) KonohaUpdater: Loaded successfully.
[22:05:12.836111] (system) Loading script 'D:\GTA San Andreas\moonloader\KonohaUpdater.lua'...
[22:05:12.836111] (debug) New script: 1ED7C33C
[22:05:12.838111] (system) KonohaUpdater: Loaded successfully.
[22:05:12.838111] (system) Loading script 'D:\GTA San Andreas\moonloader\NAVY.lua'...
[22:05:12.838111] (debug) New script: 1ED7C4E4
[22:05:12.841112] (system) NAVY: Loaded successfully.
[22:05:12.841112] (system) Loading script 'D:\GTA San Andreas\moonloader\PHelper.lua'...
[22:05:12.841112] (debug) New script: 1ED7C68C
[22:05:12.843112] (system) updatedPHelper: Loaded successfully.
[22:05:12.843112] (system) Loading script 'D:\GTA San Andreas\moonloader\reload_all.lua'...
[22:05:12.843112] (debug) New script: 1ED7C834
[22:05:12.844112] (system) ML-ReloadAll: Loaded successfully.
[22:05:12.844112] (system) Loading script 'D:\GTA San Andreas\moonloader\sekta.lua'...
[22:05:12.844112] (debug) New script: 1ED7C9DC
[22:05:12.846112] (system) sekta: Loaded successfully.
[22:05:12.846112] (system) Loading script 'D:\GTA San Andreas\moonloader\SF Integration.lua'...
[22:05:12.846112] (debug) New script: 1ED7CB84
[22:05:12.848112] (system) SF Integration: Loaded successfully.
[22:05:12.848112] (system) Loading script 'D:\GTA San Andreas\moonloader\SWATupdater.lua'...
[22:05:12.848112] (debug) New script: 1ED7CD2C
[22:05:12.850112] (system) SWATupdater: Loaded successfully.
[22:05:12.852112] (debug) Add thread 06A08BFD to SCM-thread queue
[22:05:12.852112] (debug) Add thread 06A08885 to SCM-thread queue
[22:05:12.853112] (debug) Add thread 06A0875D to SCM-thread queue
[22:05:12.853112] (debug) Add thread 06A089AD to SCM-thread queue
[22:05:12.853112] (debug) Add thread 06A0850D to SCM-thread queue
[22:05:13.037123] (debug) Add thread 06A083E5 to SCM-thread queue
[22:05:13.226134] (debug) Add thread 06A08635 to SCM-thread queue
[22:05:13.226134] (script) updatedPHelper: [PHELP] Update starts.
[22:05:13.749163] (script) updatedPHelper: [PHELP] Update successful.
[22:05:13.909173] (script) updatedPHelper: [PHELP] 1st config updated successful.
[22:05:13.909173] (script) updatedPHelper: [PHELP] 2nd config updated successful.
[22:05:14.752221] (system) Unloading...
[22:05:14.752221] (system) pisser: Script terminated. (0A02B0EC)
[22:05:14.752221] (debug) Remove thread 06A083E5 from SCM-thread queue
[22:05:14.753221] (system) ML-AutoReboot: Script terminated. (1ED7BFEC)
[22:05:14.753221] (system) KonohaUpdater: Script terminated. (1ED7C194)
[22:05:14.754221] (system) KonohaUpdater: Script terminated. (1ED7C33C)
[22:05:14.754221] (debug) Remove thread 06A08BFD from SCM-thread queue
[22:05:14.755221] (system) NAVY: Script terminated. (1ED7C4E4)
[22:05:14.755221] (debug) Remove thread 06A08885 from SCM-thread queue
[22:05:14.755221] (system) updatedPHelper: Script terminated. (1ED7C68C)
[22:05:14.755221] (debug) Remove thread 06A08635 from SCM-thread queue
[22:05:14.756221] (system) ML-ReloadAll: Script terminated. (1ED7C834)
[22:05:14.756221] (system) sekta: Script terminated. (1ED7C9DC)
[22:05:14.756221] (debug) Remove thread 06A0875D from SCM-thread queue
[22:05:14.757221] (system) SF Integration: Script terminated. (1ED7CB84)
[22:05:14.757221] (debug) Remove thread 06A089AD from SCM-thread queue
[22:05:14.757221] (system) SWATupdater: Script terminated. (1ED7CD2C)
[22:05:14.757221] (debug) Remove thread 06A0850D from SCM-thread queue
 

ShuffleBoy

Известный
Друг
754
429
Беда в том, что и sampSendChat тоже крашит скрипт. Лог пишет, что беда в этой строчке: showtagc = string.match(param, '(%d+)')
Скрипт называется NAVY, лог прикрепил ниже

[22:04:29.312622] (system) Session started.
[22:04:29.313622] (debug) Module handle: 74420000

MoonLoader v.025-beta loaded.
Developers: FYP, hnnssy, EvgeN 1137

Copyright (c) 2016, BlastHack Team
Избранное - Lua - ASI - MoonLoader(https://www.blast.hk/moonloader/)

[22:04:29.313622] (info) Working directory: D:\GTA San Andreas\moonloader
[22:04:29.313622] (debug) FP Control: 0009001F
[22:04:29.313622] (debug) Game: GTA SA 1.0.0.0 US
[22:04:29.313622] (system) Installing pre-game hooks...
[22:04:29.313622] (system) Hooks installed.
[22:04:29.862653] (debug) Initializing opcode handler table
[22:04:29.862653] (debug) package.path = D:\GTA San Andreas\moonloader\lib\?.lua;D:\GTA San Andreas\moonloader\lib\?\init.lua;D:\GTA San Andreas\moonloader\?.lua;D:\GTA San Andreas\moonloader\?\init.lua;.\?.lua;D:\GTA San Andreas\moonloader\lib\?.luac;D:\GTA San Andreas\moonloader\lib\?\init.luac;D:\GTA San Andreas\moonloader\?.luac;D:\GTA San Andreas\moonloader\?\init.luac;.\?.luac
[22:04:29.862653] (debug) package.cpath = D:\GTA San Andreas\moonloader\lib\?.dll;
[22:04:29.862653] (system) Loading script 'D:\GTA San Andreas\moonloader\33_pisser_7 (1).lua'...
[22:04:29.862653] (debug) New script: 01CB89EC
[22:04:29.866654] (system) pisser: Loaded successfully.
[22:04:29.866654] (system) Loading script 'D:\GTA San Andreas\moonloader\AutoReboot.lua'...
[22:04:29.866654] (debug) New script: 06B5CB04
[22:04:29.867654] (system) ML-AutoReboot: Loaded successfully.
[22:04:29.867654] (system) Loading script 'D:\GTA San Andreas\moonloader\imgui test.lua'...
[22:04:29.867654] (debug) New script: 06B5E324
[22:04:29.875654] (system) KonohaUpdater: Loaded successfully.
[22:04:29.875654] (system) Loading script 'D:\GTA San Andreas\moonloader\KonohaUpdater.lua'...
[22:04:29.875654] (debug) New script: 01BBA84C
[22:04:29.877654] (system) KonohaUpdater: Loaded successfully.
[22:04:29.877654] (system) Loading script 'D:\GTA San Andreas\moonloader\NAVY.lua'...
[22:04:29.877654] (debug) New script: 06B630EC
[22:04:29.880654] (system) NAVY: Loaded successfully.
[22:04:29.880654] (system) Loading script 'D:\GTA San Andreas\moonloader\PHelper.lua'...
[22:04:29.880654] (debug) New script: 06B63294
[22:04:29.882654] (system) updatedPHelper: Loaded successfully.
[22:04:29.882654] (system) Loading script 'D:\GTA San Andreas\moonloader\reload_all.lua'...
[22:04:29.882654] (debug) New script: 06B74ABC
[22:04:29.883655] (system) ML-ReloadAll: Loaded successfully.
[22:04:29.883655] (system) Loading script 'D:\GTA San Andreas\moonloader\sekta.lua'...
[22:04:29.883655] (debug) New script: 06B77E04
[22:04:29.885655] (system) sekta: Loaded successfully.
[22:04:29.885655] (system) Loading script 'D:\GTA San Andreas\moonloader\SF Integration.lua'...
[22:04:29.885655] (debug) New script: 06B77FAC
[22:04:29.888655] (system) SF Integration: Loaded successfully.
[22:04:29.888655] (system) Loading script 'D:\GTA San Andreas\moonloader\SWATupdater.lua'...
[22:04:29.888655] (debug) New script: 06B78554
[22:04:29.890655] (system) SWATupdater: Loaded successfully.
[22:04:40.943287] (system) Installing post-load hooks...
[22:04:40.943287] (system) Hooks installed.
[22:04:40.944287] (debug) Add thread 01CDA67D to SCM-thread queue
[22:04:42.388370] (script) pisser: pisser can't establish connection to rubbishman.ru
[22:04:42.448373] (debug) Add thread 06A083E5 to SCM-thread queue
[22:04:42.840396] (debug) Add thread 06A0850D to SCM-thread queue
[22:04:42.840396] (debug) Add thread 06A08635 to SCM-thread queue
[22:04:42.840396] (debug) Add thread 06A0875D to SCM-thread queue
[22:04:42.841396] (debug) Add thread 06A08885 to SCM-thread queue
[22:04:43.251419] (debug) Add thread 06A089AD to SCM-thread queue
[22:04:43.251419] (script) updatedPHelper: [PHELP] Update starts.
[22:04:43.959460] (script) updatedPHelper: [PHELP] Update successful.
[22:04:44.109468] (script) updatedPHelper: [PHELP] 1st config updated successful.
[22:04:44.109468] (script) updatedPHelper: [PHELP] 2nd config updated successful.
[22:04:45.242533] (system) Loading script 'C:\Users\tarakan2.0\AppData\Local\Temp\PHelperTEST.lua'...
[22:04:45.242533] (debug) New script: 0A02B0EC
[22:04:45.249533] (debug) Add thread 09FFB16D to SCM-thread queue
[22:04:45.256534] (system) PHelper: Loaded successfully.
[22:04:45.257534] (debug) Add thread 06A08BFD to SCM-thread queue
[22:04:47.560666] (system) Loading script 'C:\Users\tarakan2.0\AppData\Local\Temp\imgui_simple_scoreboard.lua'...
[22:04:47.560666] (debug) New script: 0A03B42C
[22:04:47.566666] (system) ImGui Scoreboard: Loaded successfully.
[22:04:48.111697] (system) Loading script 'C:\Users\tarakan2.0\AppData\Local\Temp\newMENU.lua'...
[22:04:48.111697] (debug) New script: 0A2FCF34
[22:04:48.117697] (system) PHelpFMENU: Loaded successfully.
[22:04:48.657728] (system) Loading script 'C:\Users\tarakan2.0\AppData\Local\Temp\newSpotlight.lua'...
[22:04:48.657728] (debug) New script: 0A001A04
[22:04:48.661729] (system) newSpotlight: Loaded successfully.
[22:05:09.300909] (error) NAVY: D:\GTA San Andreas\moonloader\NAVY.lua:167: bad argument #1 to 'match' (string expected, got nil)
stack traceback:
[C]: in function 'match'
D:\GTA San Andreas\moonloader\NAVY.lua:167: in function <D:\GTA San Andreas\moonloader\NAVY.lua:161>
[22:05:09.307909] (error) NAVY: Script died due to error. (06B630EC)
[22:05:09.307909] (debug) Remove thread 06A08635 from SCM-thread queue
[22:05:12.818110] (system) pisser: Script terminated. (01CB89EC)
[22:05:12.818110] (debug) Remove thread 06A083E5 from SCM-thread queue
[22:05:12.818110] (system) ML-AutoReboot: Script terminated. (06B5CB04)
[22:05:12.819110] (system) KonohaUpdater: Script terminated. (06B5E324)
[22:05:12.819110] (system) KonohaUpdater: Script terminated. (01BBA84C)
[22:05:12.819110] (debug) Remove thread 06A0850D from SCM-thread queue
[22:05:12.820110] (system) updatedPHelper: Script terminated. (06B63294)
[22:05:12.820110] (debug) Remove thread 06A089AD from SCM-thread queue
[22:05:12.820110] (system) ML-ReloadAll: Script terminated. (06B74ABC)
[22:05:12.820110] (system) sekta: Script terminated. (06B77E04)
[22:05:12.820110] (debug) Remove thread 06A0875D from SCM-thread queue
[22:05:12.821110] (system) SF Integration: Script terminated. (06B77FAC)
[22:05:12.821110] (debug) Remove thread 01CDA67D from SCM-thread queue
[22:05:12.821110] (system) SWATupdater: Script terminated. (06B78554)
[22:05:12.821110] (debug) Remove thread 06A08885 from SCM-thread queue
[22:05:12.821110] (system) PHelper: Script terminated. (0A02B0EC)
[22:05:12.821110] (debug) Remove thread 06A08BFD from SCM-thread queue
[22:05:12.823111] (system) ImGui Scoreboard: Script terminated. (0A03B42C)
[22:05:12.824111] (system) PHelpFMENU: Script terminated. (0A2FCF34)
[22:05:12.825111] (system) newSpotlight: Script terminated. (0A001A04)
[22:05:12.825111] (system) Loading script 'D:\GTA San Andreas\moonloader\33_pisser_7 (1).lua'...
[22:05:12.825111] (debug) New script: 0A02B0EC
[22:05:12.828111] (system) pisser: Loaded successfully.
[22:05:12.828111] (system) Loading script 'D:\GTA San Andreas\moonloader\AutoReboot.lua'...
[22:05:12.828111] (debug) New script: 1ED7BFEC
[22:05:12.830111] (system) ML-AutoReboot: Loaded successfully.
[22:05:12.830111] (system) Loading script 'D:\GTA San Andreas\moonloader\imgui test.lua'...
[22:05:12.830111] (debug) New script: 1ED7C194
[22:05:12.836111] (system) KonohaUpdater: Loaded successfully.
[22:05:12.836111] (system) Loading script 'D:\GTA San Andreas\moonloader\KonohaUpdater.lua'...
[22:05:12.836111] (debug) New script: 1ED7C33C
[22:05:12.838111] (system) KonohaUpdater: Loaded successfully.
[22:05:12.838111] (system) Loading script 'D:\GTA San Andreas\moonloader\NAVY.lua'...
[22:05:12.838111] (debug) New script: 1ED7C4E4
[22:05:12.841112] (system) NAVY: Loaded successfully.
[22:05:12.841112] (system) Loading script 'D:\GTA San Andreas\moonloader\PHelper.lua'...
[22:05:12.841112] (debug) New script: 1ED7C68C
[22:05:12.843112] (system) updatedPHelper: Loaded successfully.
[22:05:12.843112] (system) Loading script 'D:\GTA San Andreas\moonloader\reload_all.lua'...
[22:05:12.843112] (debug) New script: 1ED7C834
[22:05:12.844112] (system) ML-ReloadAll: Loaded successfully.
[22:05:12.844112] (system) Loading script 'D:\GTA San Andreas\moonloader\sekta.lua'...
[22:05:12.844112] (debug) New script: 1ED7C9DC
[22:05:12.846112] (system) sekta: Loaded successfully.
[22:05:12.846112] (system) Loading script 'D:\GTA San Andreas\moonloader\SF Integration.lua'...
[22:05:12.846112] (debug) New script: 1ED7CB84
[22:05:12.848112] (system) SF Integration: Loaded successfully.
[22:05:12.848112] (system) Loading script 'D:\GTA San Andreas\moonloader\SWATupdater.lua'...
[22:05:12.848112] (debug) New script: 1ED7CD2C
[22:05:12.850112] (system) SWATupdater: Loaded successfully.
[22:05:12.852112] (debug) Add thread 06A08BFD to SCM-thread queue
[22:05:12.852112] (debug) Add thread 06A08885 to SCM-thread queue
[22:05:12.853112] (debug) Add thread 06A0875D to SCM-thread queue
[22:05:12.853112] (debug) Add thread 06A089AD to SCM-thread queue
[22:05:12.853112] (debug) Add thread 06A0850D to SCM-thread queue
[22:05:13.037123] (debug) Add thread 06A083E5 to SCM-thread queue
[22:05:13.226134] (debug) Add thread 06A08635 to SCM-thread queue
[22:05:13.226134] (script) updatedPHelper: [PHELP] Update starts.
[22:05:13.749163] (script) updatedPHelper: [PHELP] Update successful.
[22:05:13.909173] (script) updatedPHelper: [PHELP] 1st config updated successful.
[22:05:13.909173] (script) updatedPHelper: [PHELP] 2nd config updated successful.
[22:05:14.752221] (system) Unloading...
[22:05:14.752221] (system) pisser: Script terminated. (0A02B0EC)
[22:05:14.752221] (debug) Remove thread 06A083E5 from SCM-thread queue
[22:05:14.753221] (system) ML-AutoReboot: Script terminated. (1ED7BFEC)
[22:05:14.753221] (system) KonohaUpdater: Script terminated. (1ED7C194)
[22:05:14.754221] (system) KonohaUpdater: Script terminated. (1ED7C33C)
[22:05:14.754221] (debug) Remove thread 06A08BFD from SCM-thread queue
[22:05:14.755221] (system) NAVY: Script terminated. (1ED7C4E4)
[22:05:14.755221] (debug) Remove thread 06A08885 from SCM-thread queue
[22:05:14.755221] (system) updatedPHelper: Script terminated. (1ED7C68C)
[22:05:14.755221] (debug) Remove thread 06A08635 from SCM-thread queue
[22:05:14.756221] (system) ML-ReloadAll: Script terminated. (1ED7C834)
[22:05:14.756221] (system) sekta: Script terminated. (1ED7C9DC)
[22:05:14.756221] (debug) Remove thread 06A0875D from SCM-thread queue
[22:05:14.757221] (system) SF Integration: Script terminated. (1ED7CB84)
[22:05:14.757221] (debug) Remove thread 06A089AD from SCM-thread queue
[22:05:14.757221] (system) SWATupdater: Script terminated. (1ED7CD2C)
[22:05:14.757221] (debug) Remove thread 06A0850D from SCM-thread queue
Сер, научитесь кидать код
 

Fomikus

Известный
Проверенный
474
343
Делает шаг и заканчивает работу скрипт
Lua:
function main()
    if not isSampLoaded() and not isSampfuncsLoaded then return end
    while not isSampAvailable() do wait(0) end
    sampRegisterChatCommand('MyBot', BotCode)
    wait(-1)
end

function BotCode()
    lua_thread.create(function ()
            sampAddChatMessage(samp, -1)
        BeginToPoint(1481.174560, -1349.359985, 113.129318, 1.000000, -255, true)
                            sampAddChatMessage(1, -1)
                wait(1000)
                                sampAddChatMessage(1, -1)
                                print(1)
        if sampIsDialogActive() then
            local id = sampGetCurrentDialogId()
            if id == 857 then
        sampSendDialogResponse(857, 1, 1, -1)
                wait(1000)
        end
        end
        BeginToPoint(1474.552246, -1349.468627, 113.13032531738, 1.000000, -255, false)
            end)
end
Принт работает.
В логе пишет просто что скрипт закончил работу.
 

3loe_ny3uko

Новичок
10
0
Сер, научитесь кидать код
Держите, мой господин.

Lua:
script_name("NAVY")
script_description("/navy")
script_version("0.1")
script_author("Soap_Mctavish")
script_dependencies("SAMPFUNCS, SAMP")
require("lib.moonloader")
require("lib.sampfuncs")

vstart = 1


function main()
  while not isSampAvailable() do
    wait(1000)
  end

if vstart == 1 then
    sampAddChatMessage("{ffffff}*[{228B22}NAVY{ffffff}]: Помощь /navy", 0xC1C1C1)
  end

  sampRegisterChatCommand("navy", navy)
  sampRegisterChatCommand("nvmed", nvmed)
  sampRegisterChatCommand("nvcom", nvcom)
  sampRegisterChatCommand("nvrp", nvrp)
  sampRegisterChatCommand("askdoc", askdoc)
  sampRegisterChatCommand("askdoc1", askdoc1)
  sampRegisterChatCommand("askdoc2", askdoc2)
  sampRegisterChatCommand("searep", searep)
  sampRegisterChatCommand("searep1", searep1)
  sampRegisterChatCommand("searep2", searep2)
  sampRegisterChatCommand("searep3", searep3)
  sampRegisterChatCommand("stopboat", stopboat)
  sampRegisterChatCommand("showtaga", showtaga)
  sampRegisterChatCommand("showtagc", showtagc)

while true do
wait(0)

end
end

function navy()
local navy = [[
{ffffff}__________________________________________________________________________________________________________

{228B22}[ NAVY ]{ffffff}   Скрипт, создан для солдат национальной гвардии в рядах ВМФ.
{228B22}[ Авторы  ]{ffffff}   Soap_Mctavish и Francisko_Murphy.
{ffffff}__________________________________________________________________________________________________________

{228B22}[ /loadnavy ] {ffffff}- Обновление скрипта до последней версии.
{ffffff}__________________________________________________________________________________________________________

{ff0000}[ Команды: ]

{228B22}[ /ustav ] {ffffff}- Устав ВМФ.
{228B22}[ /nvcom ] {ffffff}- Команды солдата ВМФ.
{228B22}[ /nvrp ] {ffffff}- Role Play отыгровки.

{ffffff}__________________________________________________________________________________________________________
]]
sampShowDialog(1010, "{ffffff} Военно-морской флот ", navy, "{ffffff}Закрыть", "", 0)
end

function nvcom()
local nvcom = [[
{ffffff}__________________________________________________________________________________________________________

{228B22}[ NAVY ]{ffffff}   Основные команды служащего ВМФ NGSA.
{ffffff}__________________________________________________________________________________________________________
{ff0000}[ Команды: ]

{228B22}[ /searep ] {ffffff}- Доклад морского патруля.

{ffffff}__________________________________________________________________________________________________________
]]
sampShowDialog(1010, "{ffffff} Команды ВМФ ", nvcom, "{ffffff}Закрыть", "", 0)
end

function nvrp()
local nvrp = [[
{ffffff}__________________________________________________________________________________________________________

{228B22}[ NAVY ]{ffffff}   Role-Play отыгровки сотрудника ВМФ.
{ffffff}__________________________________________________________________________________________________________
{ff0000}[ Команды: ]

{228B22}[ /askdoc ] {ffffff}- Попросить документы и провести обыск.
{228B22}[ /showtaga ] {ffffff}- Показать жетон спецотряда ВМФ.
{228B22}[ /showtagc ] {ffffff}- Показать жетон основного отряда ВМФ.

{ffffff}__________________________________________________________________________________________________________
]]
sampShowDialog(1010, "{ffffff} Role-Play отыгровки ", nvrp, "{ffffff}Закрыть", "", 0)
end

  function askdoc()
    sampAddChatMessage("{ffffff}*[ Мысли ]: Запрос документов [{228B22} /askdoc1 {ffffff}]. Провести обыск (обязательно после 1) [{228B22} /askdoc2 {ffffff}]", 0xC1C1C1)
  end

  function askdoc1(param)
        local result, playerID = sampGetPlayerIdByCharHandle(playerPed)
if result then
namelol = sampGetPlayerNickname(playerID)
local namel, familyl = string.match(namelol, '(%a+)_(%a+)')
    askdoc1 = string.match(param, '(%d+)')
            lua_thread.create(function()
                sampSendChat("/z Здравия желаю! Вас беспокоит боец Национальной Гвардии "..namelol.."")
                wait(2500)
                sampSendChat("/z Я состою в рядах Военно Морского Флота, сейчас я проведу обычную проверку документов")
                wait(2500)
                sampSendChat("/z В случаи отказа предоставления документов - я примею силу")
            end)
        end
    end

    function askdoc2()
      sampSendChat("/z Спасибо за предоставление документов, но это еще не всё")
            sampSendChat("{ffffff}[ Мысли ]: Мне нужно провести обыск. [{228B22} /frisk ID {ffffff}]")
    end

    function searep()
      sampAddChatMessage("{ffffff}*[ Мысли ]: Доклад патруля. Код 1 [{228B22} /searep1 {ffffff}]. Код 2 [{FFFF00} /searep2 {ffffff}]. Код 3 [{FF0000} /searep3 {ffffff}]", 0xC1C1C1)
    end

    function searep1(param)
          local result, playerID = sampGetPlayerIdByCharHandle(playerPed)
  if result then
  namelol = sampGetPlayerNickname(playerID)
  local namel, familyl = string.match(namelol, '(%a+)_(%a+)')
      searep1 = string.match(param, '(%d+)')
              lua_thread.create(function()
                  sampSendChat("/r [В.М.Ф.] Докладывает "..familyl.." | Водный патруль | Код-1")
              end)
          end
      end

      function searep2(param)
            local result, playerID = sampGetPlayerIdByCharHandle(playerPed)
    if result then
    namelol = sampGetPlayerNickname(playerID)
    local namel, familyl = string.match(namelol, '(%a+)_(%a+)')
        searep2 = string.match(param, '(%d+)')
                lua_thread.create(function()
                    sampSendChat("/r [В.М.Ф.] Докладывает "..familyl.." | Водный патруль | Код-2")
                end)
            end
        end

        function searep3(param)
              local result, playerID = sampGetPlayerIdByCharHandle(playerPed)
      if result then
      namelol = sampGetPlayerNickname(playerID)
      local namel, familyl = string.match(namelol, '(%a+)_(%a+)')
          searep3 = string.match(param, '(%d+)')
                  lua_thread.create(function()
                      sampSendChat("/[В.М.Ф.] Докладывает "..familyl.." | Водный патруль | Код-3")
                  end)
              end
          end

          function showtaga()
            local num = math.random(100000, 999999)
            local result, playerID = sampGetPlayerIdByCharHandle(playerPed)
        if result then
        namelol = sampGetPlayerNickname(playerID)
        local namel, familyl = string.match(namelol, '(%a+)_(%a+)')
            showtaga = string.match(param, '(%d+)')
            lua_thread.create(function()
              sampProcessCharInput("/me достал из под кителя жетон на цепочке и показал его")
              wait(1500)
              sampProcessCharInput("/do |=== National Guard San Andreas ===|")
              wait(2500)
              sampProcessCharInput("/do |=== № Жетона: "..num.." ===|")
              wait(2500)
              sampProcessCharInput("/do |=== Имя Фамилия: "..namelol.." ===| ")
              wait(2500)
              sampProcessCharInput("/do /do |=== Подразделение: ВМФ|А ===| ")
              end)
            end
          end

          function showtagc()
            local num = math.random(100000, 999999)
            local result, playerID = sampGetPlayerIdByCharHandle(playerPed)
          if result then
          namelol = sampGetPlayerNickname(playerID)
          local namel, familyl = string.match(namelol, '(%a+)_(%a+)')
            showtagc = string.match(param, '(%d+)')
            lua_thread.create(function()
              sampProcessCharInput("/me достал из под кителя жетон на цепочке и показал его")
              wait(1500)
              sampProcessCharInput("/do |=== National Guard San Andreas ===|")
              wait(2500)
              sampProcessCharInput("/do |=== № Жетона: "..num.." ===|")
              wait(2500)
              sampProcessCharInput("/do |=== Имя Фамилия: "..namelol.." ===| ")
              wait(2500)
              sampProcessCharInput("/do /do |=== Подразделение: ВМФ|C ===| ")
              end)
            end
          end
 

WhackerH

Новичок
43
0
Lua:
  function dh(args)
    if #args == 0 then
      sampAddChatMessage("Используйте /dh 1-3", -1)
      sampAddChatMessage("1 - LS, 2 - SF, 3 - LV", -1)
    end
    if #args == 1 then
      sampAddChatMessage("/d LSPD, 10-37 "..kvadrat(), -1)
    end
    if #args == 2 then
      sampAddChatMessage("/d SFPD, 10-37 "..kvadrat(), -1)
    end
    if #args == 3 then
      sampAddChatMessage("/d LVPD, 10-37 "..kvadrat(), -1)
    end
    if #args > 3 then
      sampAddChatMessage("Используйте /dh 1-3", -1)
      sampAddChatMessage("1 - LS, 2 - SF, 3 - LV", -1)
    end
  end
В чем ошибка? При любом значении после dh пишет
/d LSPD, 10-37 [Квадрат]
 

ShuffleBoy

Известный
Друг
754
429
Держите, мой господин.

Lua:
script_name("NAVY")
script_description("/navy")
script_version("0.1")
script_author("Soap_Mctavish")
script_dependencies("SAMPFUNCS, SAMP")
require("lib.moonloader")
require("lib.sampfuncs")

vstart = 1


function main()
  while not isSampAvailable() do
    wait(1000)
  end

if vstart == 1 then
    sampAddChatMessage("{ffffff}*[{228B22}NAVY{ffffff}]: Помощь /navy", 0xC1C1C1)
  end

  sampRegisterChatCommand("navy", navy)
  sampRegisterChatCommand("nvmed", nvmed)
  sampRegisterChatCommand("nvcom", nvcom)
  sampRegisterChatCommand("nvrp", nvrp)
  sampRegisterChatCommand("askdoc", askdoc)
  sampRegisterChatCommand("askdoc1", askdoc1)
  sampRegisterChatCommand("askdoc2", askdoc2)
  sampRegisterChatCommand("searep", searep)
  sampRegisterChatCommand("searep1", searep1)
  sampRegisterChatCommand("searep2", searep2)
  sampRegisterChatCommand("searep3", searep3)
  sampRegisterChatCommand("stopboat", stopboat)
  sampRegisterChatCommand("showtaga", showtaga)
  sampRegisterChatCommand("showtagc", showtagc)

while true do
wait(0)

end
end

function navy()
local navy = [[
{ffffff}__________________________________________________________________________________________________________

{228B22}[ NAVY ]{ffffff}   Скрипт, создан для солдат национальной гвардии в рядах ВМФ.
{228B22}[ Авторы  ]{ffffff}   Soap_Mctavish и Francisko_Murphy.
{ffffff}__________________________________________________________________________________________________________

{228B22}[ /loadnavy ] {ffffff}- Обновление скрипта до последней версии.
{ffffff}__________________________________________________________________________________________________________

{ff0000}[ Команды: ]

{228B22}[ /ustav ] {ffffff}- Устав ВМФ.
{228B22}[ /nvcom ] {ffffff}- Команды солдата ВМФ.
{228B22}[ /nvrp ] {ffffff}- Role Play отыгровки.

{ffffff}__________________________________________________________________________________________________________
]]
sampShowDialog(1010, "{ffffff} Военно-морской флот ", navy, "{ffffff}Закрыть", "", 0)
end

function nvcom()
local nvcom = [[
{ffffff}__________________________________________________________________________________________________________

{228B22}[ NAVY ]{ffffff}   Основные команды служащего ВМФ NGSA.
{ffffff}__________________________________________________________________________________________________________
{ff0000}[ Команды: ]

{228B22}[ /searep ] {ffffff}- Доклад морского патруля.

{ffffff}__________________________________________________________________________________________________________
]]
sampShowDialog(1010, "{ffffff} Команды ВМФ ", nvcom, "{ffffff}Закрыть", "", 0)
end

function nvrp()
local nvrp = [[
{ffffff}__________________________________________________________________________________________________________

{228B22}[ NAVY ]{ffffff}   Role-Play отыгровки сотрудника ВМФ.
{ffffff}__________________________________________________________________________________________________________
{ff0000}[ Команды: ]

{228B22}[ /askdoc ] {ffffff}- Попросить документы и провести обыск.
{228B22}[ /showtaga ] {ffffff}- Показать жетон спецотряда ВМФ.
{228B22}[ /showtagc ] {ffffff}- Показать жетон основного отряда ВМФ.

{ffffff}__________________________________________________________________________________________________________
]]
sampShowDialog(1010, "{ffffff} Role-Play отыгровки ", nvrp, "{ffffff}Закрыть", "", 0)
end

  function askdoc()
    sampAddChatMessage("{ffffff}*[ Мысли ]: Запрос документов [{228B22} /askdoc1 {ffffff}]. Провести обыск (обязательно после 1) [{228B22} /askdoc2 {ffffff}]", 0xC1C1C1)
  end

  function askdoc1(param)
        local result, playerID = sampGetPlayerIdByCharHandle(playerPed)
if result then
namelol = sampGetPlayerNickname(playerID)
local namel, familyl = string.match(namelol, '(%a+)_(%a+)')
    askdoc1 = string.match(param, '(%d+)')
            lua_thread.create(function()
                sampSendChat("/z Здравия желаю! Вас беспокоит боец Национальной Гвардии "..namelol.."")
                wait(2500)
                sampSendChat("/z Я состою в рядах Военно Морского Флота, сейчас я проведу обычную проверку документов")
                wait(2500)
                sampSendChat("/z В случаи отказа предоставления документов - я примею силу")
            end)
        end
    end

    function askdoc2()
      sampSendChat("/z Спасибо за предоставление документов, но это еще не всё")
            sampSendChat("{ffffff}[ Мысли ]: Мне нужно провести обыск. [{228B22} /frisk ID {ffffff}]")
    end

    function searep()
      sampAddChatMessage("{ffffff}*[ Мысли ]: Доклад патруля. Код 1 [{228B22} /searep1 {ffffff}]. Код 2 [{FFFF00} /searep2 {ffffff}]. Код 3 [{FF0000} /searep3 {ffffff}]", 0xC1C1C1)
    end

    function searep1(param)
          local result, playerID = sampGetPlayerIdByCharHandle(playerPed)
  if result then
  namelol = sampGetPlayerNickname(playerID)
  local namel, familyl = string.match(namelol, '(%a+)_(%a+)')
      searep1 = string.match(param, '(%d+)')
              lua_thread.create(function()
                  sampSendChat("/r [В.М.Ф.] Докладывает "..familyl.." | Водный патруль | Код-1")
              end)
          end
      end

      function searep2(param)
            local result, playerID = sampGetPlayerIdByCharHandle(playerPed)
    if result then
    namelol = sampGetPlayerNickname(playerID)
    local namel, familyl = string.match(namelol, '(%a+)_(%a+)')
        searep2 = string.match(param, '(%d+)')
                lua_thread.create(function()
                    sampSendChat("/r [В.М.Ф.] Докладывает "..familyl.." | Водный патруль | Код-2")
                end)
            end
        end

        function searep3(param)
              local result, playerID = sampGetPlayerIdByCharHandle(playerPed)
      if result then
      namelol = sampGetPlayerNickname(playerID)
      local namel, familyl = string.match(namelol, '(%a+)_(%a+)')
          searep3 = string.match(param, '(%d+)')
                  lua_thread.create(function()
                      sampSendChat("/[В.М.Ф.] Докладывает "..familyl.." | Водный патруль | Код-3")
                  end)
              end
          end

          function showtaga()
            local num = math.random(100000, 999999)
            local result, playerID = sampGetPlayerIdByCharHandle(playerPed)
        if result then
        namelol = sampGetPlayerNickname(playerID)
        local namel, familyl = string.match(namelol, '(%a+)_(%a+)')
            showtaga = string.match(param, '(%d+)')
            lua_thread.create(function()
              sampProcessCharInput("/me достал из под кителя жетон на цепочке и показал его")
              wait(1500)
              sampProcessCharInput("/do |=== National Guard San Andreas ===|")
              wait(2500)
              sampProcessCharInput("/do |=== № Жетона: "..num.." ===|")
              wait(2500)
              sampProcessCharInput("/do |=== Имя Фамилия: "..namelol.." ===| ")
              wait(2500)
              sampProcessCharInput("/do /do |=== Подразделение: ВМФ|А ===| ")
              end)
            end
          end

          function showtagc()
            local num = math.random(100000, 999999)
            local result, playerID = sampGetPlayerIdByCharHandle(playerPed)
          if result then
          namelol = sampGetPlayerNickname(playerID)
          local namel, familyl = string.match(namelol, '(%a+)_(%a+)')
            showtagc = string.match(param, '(%d+)')
            lua_thread.create(function()
              sampProcessCharInput("/me достал из под кителя жетон на цепочке и показал его")
              wait(1500)
              sampProcessCharInput("/do |=== National Guard San Andreas ===|")
              wait(2500)
              sampProcessCharInput("/do |=== № Жетона: "..num.." ===|")
              wait(2500)
              sampProcessCharInput("/do |=== Имя Фамилия: "..namelol.." ===| ")
              wait(2500)
              sampProcessCharInput("/do /do |=== Подразделение: ВМФ|C ===| ")
              end)
            end
          end
function showtaga() >> function showtaga(param)
 

#Northn

Pears Project — уже запущен!
Всефорумный модератор
2,643
2,493
Lua:
  function dh(args)
    if #args == 0 then
      sampAddChatMessage("Используйте /dh 1-3", -1)
      sampAddChatMessage("1 - LS, 2 - SF, 3 - LV", -1)
    end
    if #args == 1 then
      sampAddChatMessage("/d LSPD, 10-37 "..kvadrat(), -1)
    end
    if #args == 2 then
      sampAddChatMessage("/d SFPD, 10-37 "..kvadrat(), -1)
    end
    if #args == 3 then
      sampAddChatMessage("/d LVPD, 10-37 "..kvadrat(), -1)
    end
    if #args > 3 then
      sampAddChatMessage("Используйте /dh 1-3", -1)
      sampAddChatMessage("1 - LS, 2 - SF, 3 - LV", -1)
    end
  end
В чем ошибка? При любом значении после dh пишет
Потому что #args указывает на количество, используй:
Lua:
function dh(param)
    local number = string.match(param, '(%d+)')
    if number ~= nil then
    if number == 1 then
      sampAddChatMessage("/d LSPD, 10-37 "..kvadrat(), -1)
    end
    if number == 2 then
      sampAddChatMessage("/d SFPD, 10-37 "..kvadrat(), -1)
    end
    if number == 3 then
      sampAddChatMessage("/d LVPD, 10-37 "..kvadrat(), -1)
    end
    if number > 3 then
      sampAddChatMessage("Используйте /dh 1-3", -1)
      sampAddChatMessage("1 - LS, 2 - SF, 3 - LV", -1)
    end
    else
      sampAddChatMessage("Используйте /dh 1-3", -1)
      sampAddChatMessage("1 - LS, 2 - SF, 3 - LV", -1)
    end
end