From 61506bf947eb9c5a6fef43f8320ba3cea50fa94e Mon Sep 17 00:00:00 2001 From: rubin Date: Sat, 18 Feb 2023 22:42:03 +0300 Subject: [PATCH] fixed dialog --- squad-mats.lua | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/squad-mats.lua b/squad-mats.lua index 5b4329b..9b3613f 100644 --- a/squad-mats.lua +++ b/squad-mats.lua @@ -23,9 +23,6 @@ function main() addChatMessage("Установлен новый ID сквада: "..config.data.squad_id) end end) - sampRegisterChatCommand("test",function(para) - dialog.reshow() - end) wait(-1) end @@ -123,22 +120,6 @@ dialog.convertText = function(text) text = string.format("%s\n \nВсего потрачено: %d матов\nСтоимость: %d вирт\n> Оплатить сейчас", text, config.data.mats, (config.data.mats * config.data.mats_price)) return text end -dialog.reshow = function() - local text = dialog.convertText(dialog.text) - local bs = raknetNewBitStream() - raknetBitStreamWriteInt16(bs, dialog.id) - raknetBitStreamWriteInt8(bs, 2) - raknetBitStreamWriteInt8(bs, 4) - raknetBitStreamWriteString(bs, Utf8ToAnsi("Меню")) - raknetBitStreamWriteInt8(bs, 7) - raknetBitStreamWriteString(bs, Utf8ToAnsi("Выбрать")) - raknetBitStreamWriteInt8(bs, 7) - raknetBitStreamWriteString(bs, Utf8ToAnsi("Закрыть")) - raknetBitStreamWriteInt8(bs, string.len(text)) - raknetBitStreamWriteString(bs, Utf8ToAnsi(text)) - raknetEmulRpcReceiveBitStream(61,bs) - raknetDeleteBitStream(bs) -end -->> EVENTS function sampev.onServerMessage(color, message) @@ -146,14 +127,13 @@ function sampev.onServerMessage(color, message) local weapon = message:match("%[Офис%]{FFFFFF} Вы взяли {00FFBF}(.+) %(%d+ .+%) {FFFFFF}с оружейного шкафа офиса!") config.data.mats = config.data.mats + counter.weapon[weapon] config.save(config.data) - --lua_thread.create(dialog.reshow) end - if message == " Операция выполнена" and os.time() - counter.reset <= 2 then + if message:find(" Операция выполнена") and os.time() - counter.reset <= 2 then addChatMessage("Счетчик материалов обнулен!") config.data.mats = 0 config.save(config.data) end - if message == " Вы не в сообществе" and os.time() - counter.reset <= 2 then + if message:find(" Вы не в сообществе") and os.time() - counter.reset <= 2 then addChatMessage("Укажите ID сообщества командой /squadid [ID]") end end @@ -165,11 +145,12 @@ function sampev.onShowDialog(dialogId, style, title, button1, button2, text) end end function sampev.onSendDialogResponse(dialogId, button, listboxId, input) - if listboxId == 10 then + if dialog.id == dialogId and listboxId == 10 and button == 1 then counter.reset = os.time() sampSendChat("/squad bank "..config.data.squad_id.." "..(config.data.mats * config.data.mats_price)) return false end + dialog.id = -1 end -->> NEW FUNCTION