diff --git a/mafia-tools.lua b/mafia-tools.lua index 325a97d..d03a144 100644 --- a/mafia-tools.lua +++ b/mafia-tools.lua @@ -33,6 +33,7 @@ function main() lua_thread.create(healme.loop) lua_thread.create(armoff.loop) lua_thread.create(clistoff.loop) + lua_thread.create(stream_checker.loop) sampRegisterChatCommand("int",function() local int = getActiveInterior() @@ -580,6 +581,44 @@ menu.update = function() menu.show = { true, "main" } end }, + { -->> Список отсутствующих + title = "{"..config.data.font.color1.."}".."Список отсутствующих\t", + click = function(button, list, input , outs) + if button ~= 1 then return end + menu.show = { true, "main" } + end + }, + { -->> Отправить по команде + title = "{"..config.data.font.color1.."}"..">{ffffff} Отправить по команде\t/"..config.data.stream_checker, + click = function(button, list, input , outs) + if button ~= 1 then return end + menu.show = { true, "edit", function(button, list, input, outs) + if button == 1 then + if #input > 0 then + config.data.stream_checker = input + config.save(config.data) + end + end + menu.show = { true, "main" } + end, config.data.stream_checker, "Введите название команды\nПо умолчанию: progul"} + end + }, + { -->> Отправлять ID или Ники + title = "{"..config.data.font.color1.."}"..">{ffffff} Режим\t"..(config.data.stream_checker_name and "Ник[ID] - Ранг" or "Только ID"), + click = function(button, list, input , outs) + if button ~= 1 then return end + config.data.stream_checker_name = not config.data.stream_checker_name + config.save(config.data) + menu.show = { true, "main" } + end + }, + { -->> Разделитель + title = " \t ", + click = function(button, list, input , outs) + if button ~= 1 then return end + menu.show = { true, "main" } + end + }, { -->> ПРочее title = "{"..config.data.font.color1.."}".."Прочее\t", click = function(button, list, input , outs) @@ -615,6 +654,15 @@ menu.update = function() end, armoff_list, "Введите ID стрел на которых нужно оффать броню\nВведите ID через пробел\nПример: 0 1 3"} end }, + { -->> clistoff + title = "{"..config.data.font.color1.."}"..">{ffffff} clist off при спавне/после стрелы\t"..(config.data.clistoff and "вкл" or "выкл"), + click = function(button, list, input , outs) + if button ~= 1 then return end + config.data.clistoff = not config.data.clistoff + config.save(config.data) + menu.show = { true, "main" } + end + }, } }, ["edit"] = { @@ -785,7 +833,90 @@ menu.loop = function() end end --- CLISTOFF +-->> STREAM CHECKER +stream_checker = {} +stream_checker.hide = 0 +stream_checker.members = {} +stream_checker.sender = {} +stream_checker.textfuncs = { + ['%[ID%]Имя {C0C0C0}Ранг%[Номер%] {6495ED}%[AFK секунд%] {C0C0C0}Бан чата'] = function(message) + stream_checker.members = {} + return true + end, + ['%[(%d+)%] (.+) {C0C0C0}.+ %[.+%](.+)'] = function(message) + local id, name, rank, afk = string.match(message, '%[(%d+)%] (.+) {C0C0C0}(.+ %[.+%])(.+)') + local result, ped = sampGetCharHandleBySampPlayerId(id) + if not result and tonumber(id) ~= getLocalPlayerId() then + stream_checker.members[name] = { id = id, rank = rank } + end + return true + end, + ['Всего онлайн: %d+'] = function(message) + local sender = {} + if config.data.stream_checker_name then + for name, data in pairs(stream_checker.members) do + name = name:gsub(" ", "") + sender[#sender+1] = string.format("/rb %s[%s] - %s", name, data.id, data.rank:gsub(" %[", "[")) + end + else + local ids = "" + for name, data in pairs(stream_checker.members) do + ids = ids..data.id.." " + if #ids > 40 then + sender[#sender+1] = string.format("/rb %s", ids) + ids = "" + end + end + if #ids > 0 then + sender[#sender+1] = string.format("/rb %s", ids) + end + end + if #sender > 0 then + sender[#sender+1] = string.format("/rb Список отсутствующих") + end + stream_checker.sender = sender + return true + end, +} +stream_checker.onServerMessage = function(color, message) + if os.time() - stream_checker.hide < 3 then + if message == " " or message == "===========================================" then + return false + end + for k,v in pairs(stream_checker.textfuncs) do + if message:find(k) then + if v(message) then + return false + end + end + end + end +end +stream_checker.onSendCommand = function(cmd) + if cmd == string.format("/%s", config.data.stream_checker) then + stream_checker.hide = os.time() + sampSendChat("/members") + return false + end +end +stream_checker.loop = function() + while true do + wait(0) + if #stream_checker.sender > 0 then + printStringNow("~Y~PRESS 'L' STOP~N~"..#stream_checker.sender, 1) + if isKeyCanBePressed() and wasKeyPressed(76) then -->> 76 VK_L + stream_checker.sender = {} + msg.add("Отправка остановлена.") + end + if antiflood.get() > 700 then + sampSendChat(stream_checker.sender[1]) + table.remove(stream_checker.sender, 1) + end + end + end +end + +-->> CLISTOFF clistoff = {} clistoff.onServerMessage = function(color, message) if message == " (( Чтобы посмотреть правила проведения войны за бизнес введите /mrules ))" then @@ -796,6 +927,9 @@ clistoff.onServerMessage = function(color, message) clistoff.war = false clistoff.start = true end + if message == " Нельзя использовать во время войны" then + clistoff.war = true + end end clistoff.loop = function() clistoff.war = false @@ -806,7 +940,7 @@ clistoff.loop = function() if not clistoff.war and clistoff.start and os.time() - clistoff.wait > 3 then local id = getLocalPlayerId() local color = sampGetPlayerColor(id) - if color ~= 16777215 then + if color ~= 16777215 and config.data.clistoff then antiflood.add("/clist 0") end clistoff.start = false @@ -814,8 +948,13 @@ clistoff.loop = function() end end end +clistoff.spawn = function() + clistoff.wait = os.time() + clistoff.war = false + clistoff.start = true +end --- ARMOFF +-->> ARMOFF armoff = {} armoff.onServerMessage = function(color, message) if message:find("Война за бизнес %{6AB1FF%}.+ %{FFFFFF%}пройдет в %{6AB1FF%}.+ %{FFFFFF%}| ID: %{6AB1FF%}(%d+)") then @@ -864,7 +1003,7 @@ armoff.check = function() return result end --- HEALME +-->> HEALME healme = {} healme.old_interior = -1 healme.sended = 0 @@ -1780,7 +1919,9 @@ config.default = { offset_wait = 1 }, healme = true, - clistoff = true + clistoff = true, + stream_checker = "progul", + stream_checker_name = false, --> 0 - Только ID | 1 - Флудить никами } config.directory = string.format("%s\\moonloader\\config\\%s\\", getGameDirectory(), thisScript().name) config.init = function() @@ -1893,6 +2034,10 @@ function sampev.onSendCommand(cmd) if res then return table.unpack(res) end + local res = processEvent(stream_checker.onSendCommand, table.pack(cmd)) + if res then + return table.unpack(res) + end end function sampev.onSendChat(message) antiflood.set() @@ -1933,6 +2078,20 @@ function onSendPacket(id, bs) end end end +function onReceiveRpc(id,bs) + if id == 93 then + local color = raknetBitStreamReadInt32(bs) + local len = raknetBitStreamReadInt32(bs) + local message = raknetBitStreamReadString(bs,len) + local res = processEvent(stream_checker.onServerMessage, table.pack(color, AnsiToUtf8(message))) + if res then + return table.unpack(res) + end + end +end +function sampev.onSendSpawn() + clistoff.spawn() +end function sampev.onResetPlayerWeapons() get_guns.onResetPlayerWeapons() end