From b1f14921412809cb74b46371a8b8c0734876e4f4 Mon Sep 17 00:00:00 2001 From: rubin Date: Tue, 31 Jan 2023 22:36:54 +0300 Subject: [PATCH] added handler black/white list & added show list dialog --- mafia-tools.lua | 66 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 46 insertions(+), 20 deletions(-) diff --git a/mafia-tools.lua b/mafia-tools.lua index 2265a09..5b0ed8d 100644 --- a/mafia-tools.lua +++ b/mafia-tools.lua @@ -42,21 +42,28 @@ menu.color = "{fffd8f}" menu.data = {} menu.update = function() + -->> Список блокировщика + local blacklist = {} + for k,v in pairs(config.data.list) do + blacklist[#blacklist+1] = { + title = k, + click = function(button, list, input , outs) + if button == 1 then + config.data.list[k] = nil + config.save(config.data) + addChatMessage(string.format("Вы удалили %s из списка!", k)) + end + menu.show = { true, "main" } + end + } + end + -->> Обновление инфы от сервера local players = getNicknamesOnline() local count = 0 local members = {} for sender, sender_data in pairs(menu.data) do count = count + 1 - -- for key, v in pairs(sender_data) do - -- if ammo_timer.data[key] ~= nil then - -- if ammo_timer.data[key]["time"] < v["time"] then - -- ammo_timer.data[key]["time"] = v["time"] - -- ammo_timer.data[key]["text"] = v["text"] - -- end - -- end - -- end - members[#members+1] = { title = string.format("%s\t", (players[sender] ~= nil and sender.."["..players[sender].."]" or sender)), click = function(button, list, input, outs) @@ -118,13 +125,8 @@ menu.update = function() end end } - - end - - - menu.dialog = { ["main"] = { settings = {title = "mafia-tools" ,style = 4 ,btn1 = "Выбрать" ,btn2 = "Закрыть" ,forward = "{ffffff}" ,backwards = "\n" ,score = false}, @@ -162,7 +164,11 @@ menu.update = function() title = menu.color..">{ffffff} Список блокировщика\t", click = function(button, list, input , outs) if button ~= 1 then return end - + if #blacklist > 0 then + menu.show = { true, "members_user", blacklist } + else + menu.show = { true, "main" } + end end }, { @@ -265,18 +271,38 @@ request.handler = function(text) end if info["result"] == "ok" then menu.data = info["data"] + local new_data = { + ls = { time = 0, text = "00:00:00" }, + sf = { time = 0, text = "00:00:00" }, + lv = { time = 0, text = "00:00:00" }, + mhcars = { time = 0, text = "00:00:00" }, + } + local isPlayerInList = function(sender) + local result = false + if config.data.list_block then + if config.data.list[sender] == nil then + result = true + end + else + if config.data.list[sender] ~= nil then + result = true + end + end + return result + end for sender, sender_data in pairs(info["data"]) do - if config.data.list[sender] == nil then + if isPlayerInList(sender) then for key, v in pairs(sender_data) do - if ammo_timer.data[key] ~= nil then - if ammo_timer.data[key]["time"] < v["time"] then - ammo_timer.data[key]["time"] = v["time"] - ammo_timer.data[key]["text"] = v["text"] + if new_data[key] ~= nil then + if new_data[key]["time"] < v["time"] then + new_data[key]["time"] = v["time"] + new_data[key]["text"] = v["text"] end end end end end + ammo_timer.data = new_data end return true end