помощь по коду

KeCu

Участник
Автор темы
35
3
local key = 85 -- КНОПКА ВЫЗОВА ДИАЛОГА ПО ТАРГЕТУ ||

function main()
if not isSampLoaded() or not isSampfuncsLoaded() then return end
while not isSampAvailable() do wait(100) end
dir = getGameDirectory().."\\moonloader\\config"
if not doesDirectoryExist(dir) then createDirectory(dir) end
dir = getGameDirectory().."\\moonloader\\config\\FastSU\\"
if not doesDirectoryExist(dir) then
createDirectory(dir)
if not doesFileExist(dir.."Статья 1. Тестовая.txt") then
local text = "<Заголовок если надо, можно не использовать>\n[5] [1.1 Текст для диалога] [Текст для причины (УК 1.1)]"
file = io.open(dir.."Статья 1. Тестовая.txt", "a")
file:write(text)
file:flush()
io.close(file)
end
end
sampRegisterChatCommand("su", su)
while true do
wait(0)
local result, button, list, input = sampHasDialogRespond(2501)
if result then
if button == 1 and dialogAdress
  • ~= nil then
    local file = io.open(dialogAdress
    • , "r")
      if file ~= nil then
      dialog = {}
      dialogText = ""
      list = 0
      for line in file:lines() do
      local stars, dialogReason, chatReason = string.match(line, "%[(.+)%].+%[(.+)%].+%[(.+)%]")
      if stars ~= nil then
      dialog
      • = string.format("/su %d %s %s", playerid, stars, chatReason)
        dialogText = string.format("%s%s\n", dialogText, dialogReason)
        end
        local caption = string.match(line, "%<(.+)%>")
        if caption ~= nil then
        dialogText = string.format("%s%s\n", dialogText, caption)
        end
        list = list + 1
        end
        io.close(file)
        sampShowDialog(2502, "[FastSU.lua] [Автор: Serhiy_Rubin]", dialogText, "Выбрать", "Назад", 2)
        end
        end
        end
        local result, button, list, input = sampHasDialogRespond(2502)
        if result then
        if button == 1 then
        if dialog
        • ~= nil then
          sampSendChat(dialog
          • )
            else
            ShowDialog()
            end
            else
            ShowDialog()
            end
            end
            local result, handle = getCharPlayerIsTargeting(playerHandle)
            if result then
            if wasKeyPressed(key) then
            _, playerid = sampGetPlayerIdByCharHandle(handle)
            ShowDialog()
            end
            end
            end
            end

            function su(param)
            if string.find(param, "(%d+)") and #param <= 3 then
            playerid = string.match(param, "(%d+)")
            ShowDialog(param)
            else
            sampSendChat("/su "..param)
            end
            end

            function ShowDialog()
            if dir ~= nil then
            local FileHandle, FileName = findFirstFile(dir.."\\*")
            if FileHandle ~= nil then
            list = 0
            dialogText = ""
            dialogAdress = {}
            while FileName ~= nil do
            if FileName ~= nil and FileName ~= ".." and FileName ~= "." then
            dialogAdress
            • = dir..FileName
              dialogText = string.format("%s%s\n", dialogText, FileName)
              list = list + 1
              end
              FileName = findNextFile(FileHandle)
              end
              findClose(FileHandle)
              sampShowDialog(2501, "[FastSU.lua] [Автор: Serhiy_Rubin]", dialogText, "Выбрать", "Закрыть", 2)
              end
              end
              end
помогите( почему так(
 

Вложения

  • 2023-12-24 23-45-12-929.png
    2023-12-24 23-45-12-929.png
    2.2 MB · Просмотры: 12