From 8491561766c44f38b5654391cd09f3248fd28cc4 Mon Sep 17 00:00:00 2001 From: rubin Date: Fri, 10 Feb 2023 22:12:15 +0300 Subject: [PATCH] set url test & added new request param --- mafia-tools.lua | 205 +++++++++++++++++++++++++++++------------------- 1 file changed, 125 insertions(+), 80 deletions(-) diff --git a/mafia-tools.lua b/mafia-tools.lua index e64e536..986db63 100644 --- a/mafia-tools.lua +++ b/mafia-tools.lua @@ -778,6 +778,9 @@ end mhcars = {} mhcars.time = 0 mhcars.onServerMessage = function(color, message) + if message == " Вы не являетесь лидером/замом мафии" then + mhcars.time = os.time() + 1800 + end if message == " Задание уже начато" then mhcars.time = os.time() + 1800 end @@ -800,21 +803,28 @@ mhcars.onServerMessage = function(color, message) mhTimer = mhTimer + tonumber(p2) end mhcars.time = os.time() + mhTimer - config.data.mhcars.offset_wait + request.send[#request.send + 1] = { + key = "mhcars", + second = mhTimer + } + request.wait = 0 end end --> by Richard_Holmes end mhcars.loop = function() while true do wait(0) - if mhcars.time == 0 then - if mhcars.antiflood == nil or os.time() - mhcars.antiflood > 1 then - mhcars.antiflood = os.time() - antiflood.send[#antiflood.send+1] = "/mhcars "..config.data.mhcars.gang + if sampIsLocalPlayerSpawned() and isPlayerInMafia() and config.data.stats.rank >= 9 then + if mhcars.time == 0 then + if mhcars.antiflood == nil or os.time() - mhcars.antiflood > 1 then + mhcars.antiflood = os.time() + antiflood.add("/mhcars "..config.data.mhcars.gang) + end end - end - if mhcars.time ~= 0 and os.time() > mhcars.time then - if antiflood.get() > config.data.mhcars.wait then - sampSendChat("/mhcars "..config.data.mhcars.gang) + if mhcars.time ~= 0 and os.time() > mhcars.time then + if antiflood.get() > config.data.mhcars.wait then + sampSendChat("/mhcars "..config.data.mhcars.gang) + end end end end @@ -883,22 +893,31 @@ end mafiawar.loop = function() while true do wait(0) - if config.data.mafiawar.auto and mafiawar.biz then - if mafiawar.time == 0 then - if mafiawar.antiflood == nil or os.time() - mafiawar.antiflood > 1 then - mafiawar.antiflood = os.time() - antiflood.send[#antiflood.send+1] = "/mafiawar "..config.data.mafiawar.id + if sampIsLocalPlayerSpawned() and isPlayerInMafia() and config.data.stats.rank >= 6 then + if config.data.mafiawar.auto and mafiawar.biz then + if mafiawar.time == 0 then + if mafiawar.antiflood == nil or os.time() - mafiawar.antiflood > 1 then + mafiawar.antiflood = os.time() + antiflood.send[#antiflood.send+1] = "/mafiawar "..config.data.mafiawar.id + end end - end - if mafiawar.time ~= 0 and os.time() >= mafiawar.time then - if antiflood.get() > config.data.mafiawar.wait then - sampSendChat("/mafiawar "..config.data.mafiawar.id) + if mafiawar.time ~= 0 and os.time() >= mafiawar.time then + if antiflood.get() > config.data.mafiawar.wait then + sampSendChat("/mafiawar "..config.data.mafiawar.id) + end end end end end end +-->> CHECK STATS +function isPlayerInMafia() + if config.data.stats.frac == "LCN" or config.data.stats.frac == "Yakuza" or config.data.stats.frac == "Russian Mafia" then + return true + end +end + -->> GET GUNS get_guns = {} get_guns.warehouse = false @@ -940,15 +959,23 @@ get_guns.onServerMessage = function(color, message) if message:find("^ %d+/%d+ Матов | %d+/%d+ Аптечек") and os.time() - get_guns.check_warehouse_time < 2 then return false end - if message:find("^ .+%[%d+%]: (.+)") then + if message:find("^ .+%[%d+%]: (.+)") and color == 33357823 then get_guns.messages[#get_guns.messages+1] = message:match("^ .+%[%d+%]: (.+)") end - if config.data.get_guns.auto_get_guns and get_guns.enter_textdraw and message:find("^ .+ открыл%(а%) склад с оружием$") and not message:find(getLocalPlayerNickname()) then + if message:find("^ .+ открыл%(а%) склад с оружием$") then get_guns.warehouse = true - get_guns.start_get() + if not message:find(getLocalPlayerNickname()) then + get_guns.warelock_send = {} + if config.data.get_guns.auto_get_guns and get_guns.enter_textdraw then + get_guns.start_get() + end + end end - if message:find("^ .+ открыл%(а%) склад с оружием$") and not message:find(getLocalPlayerNickname()) then - get_guns.warelock_send = {} + if message:find("^ .+ закрыл%(а%) склад с оружием$") then + get_guns.warehouse = false + if not message:find(getLocalPlayerNickname()) then + get_guns.warelock_send = {} + end end if message == " Броня уже 100%" and get_guns.getgun then antiflood.send[#antiflood.send+1] = "/getgun" @@ -971,8 +998,12 @@ end get_guns.onShowDialog = function(id, style, title, button1, button2, text) if title == "Статистика персонажа" then local frac, rank = text:match("Организация\t(.+).Ранг\t.+%[(.+)%]") + if frac == nil then + frac, rank = text:match("Организация\t(.+).Ранг\t(.+).Работа") + end if rank ~= nil then - rank = rank:gsub("лидер", "10") + rank = rank:gsub("Нет", 0) + rank = rank:gsub("лидер", 10) rank = tonumber(rank) config.data.stats.rank = rank config.data.stats.frac = frac @@ -1022,45 +1053,47 @@ get_guns.loop = function() antiflood.send[#antiflood.send+1] = "/stats" end elseif not get_guns.check_warehouse then - if sampIsLocalPlayerSpawned() and os.time() - get_guns.antiflood > 30 then + if sampIsLocalPlayerSpawned() and isPlayerInMafia() and os.time() - get_guns.antiflood > 30 then get_guns.antiflood = os.time() antiflood.send[#antiflood.send+1] = "/warehouse" end end - if get_guns.enter_textdraw and isKeyCanBePressed() and isKeysPressed(config.data.get_guns.key) and not get_guns.getgun then - get_guns.start_get() - else - if isKeysPressed(config.data.get_guns.key) and get_guns.getgun then - msg.add("Выполняется взятие ганов") + if isPlayerInMafia() then + if get_guns.enter_textdraw and isKeyCanBePressed() and isKeysPressed(config.data.get_guns.key) and not get_guns.getgun then + get_guns.start_get() + else + if isKeysPressed(config.data.get_guns.key) and get_guns.getgun then + msg.add("Выполняется взятие ганов") + end end - end - if #get_guns.messages > 0 then - if config.data.get_guns.warelock_auto and not get_guns.warehouse and config.data.stats.rank >= 8 then - local result = false - local text = split(get_guns.messages[1], " ") - for i = 1, #config.data.get_guns.warelock_text do - for p = 1, #text do - if text[p] == config.data.get_guns.warelock_text[i] then - result = true + if #get_guns.messages > 0 then + if config.data.get_guns.warelock_auto and not get_guns.warehouse and config.data.stats.rank >= 8 then + local result = false + local text = split(get_guns.messages[1], " ") + for i = 1, #config.data.get_guns.warelock_text do + for p = 1, #text do + if text[p] == config.data.get_guns.warelock_text[i] then + result = true + end end end + if result then + local rand = math.random(1, 5) + get_guns.warelock_send = { + { os.time() + rand, false }, + { os.time() + config.data.get_guns.warelock_time + rand, true } + } + end end - if result then - local rand = math.random(1, 5) - get_guns.warelock_send = { - { os.time() + rand, false }, - { os.time() + config.data.get_guns.warelock_time + rand, true } - } - end + table.remove(get_guns.messages, 1) end - table.remove(get_guns.messages, 1) - end - if #get_guns.warelock_send > 0 then - if get_guns.warelock_send[1][1] < os.time() then - if get_guns.warelock_send[1][2] == get_guns.warehouse then - antiflood.send[#antiflood.send+1] = "/warelock" + if #get_guns.warelock_send > 0 then + if get_guns.warelock_send[1][1] < os.time() then + if get_guns.warelock_send[1][2] == get_guns.warehouse then + antiflood.send[#antiflood.send+1] = "/warelock" + end + table.remove(get_guns.warelock_send, 1) end - table.remove(get_guns.warelock_send, 1) end end end @@ -1178,6 +1211,17 @@ antiflood.loop = function() end end end +antiflood.add = function(text) + local result = true + for i = 1, #antiflood.send do + if antiflood.send[i] == text then + result = false + end + end + if result then + antiflood.send[#antiflood.send+1] = text + end +end -->> MAFIA CHECKER mafia_checker = {} @@ -1257,21 +1301,31 @@ request = {} request.chat = {} request.send = {} request.base = {} +request.warelock = false request.loop = function() request.wait = 0 while true do wait(0) if os.time() - request.wait >= 5 then + --> Может ли игрок открыть склад? + local can_warelock = false + if config.data.stats.rank >= 8 and config.data.get_guns.warelock_auto then + can_warelock = true + end + request.wait = os.time() local request_table = { sender = getLocalPlayerNickname(), server = getServerAddress(), room = config.data.room, send = request.send, + can_warelock = can_warelock, + request_warelock = request.warelock rand = os.clock() } request.send = {} - local url = string.format("http://mafia.deadpoo.net/%s", urlencode(encodeJson(request_table))) + request.warelock = false + local url = string.format("http://mafia-test.deadpoo.net/%s", urlencode(encodeJson(request_table))) local result, text = pcall(openURL, url, os.tmpname(), true) if result then local result = pcall(request.handler, text) @@ -1366,28 +1420,6 @@ ammo_timer.onServerMessage = function(color, message) end end end - if message:find("^ Задание будет доступно через: ") then - local p1, p2, p3 = string.match(message, "Задание будет доступно через: (%d+):(%d+):(%d+)") - if(p3 == nil)then - p1, p2 = string.match(message, "Задание будет доступно через: (%d+):(%d+)") - end - if(p1 ~= nil and p2 ~= nil)then - local mhTimer = 0 - if(p3 ~= nil)then - mhTimer = tonumber(p1) * 3600 - mhTimer = mhTimer + (tonumber(p2) * 60) - mhTimer = mhTimer + tonumber(p3) - else - mhTimer = mhTimer + (tonumber(p1) * 60) - mhTimer = mhTimer + tonumber(p2) - end - request.send[#request.send + 1] = { - key = "mhcars", - second = mhTimer - } - request.wait = 0 - end - end --> by Richard_Holmes if message:find(".+ заказал спавн транспорта через %d+ секунд%. С банка фракции снято %d+ вирт$") then request.send[#request.send + 1] = { key = "ffixcar", @@ -1659,13 +1691,26 @@ function sampev.onSendPickedUpPickup(id) ["sf"] = {x = -2626.4050292969, y = 210.6088104248, z = 4.6033186912537}, ["lv"] = {x = 2158.3286132813, y = 943.17541503906, z = 10.371940612793} } - ammo_timer.last_ammo = "" - for k, v in pairs(ammo) do - local distance = getDistanceBetweenCoords3d(X, Y, Z, v.x, v.y, v.z) + local ignore_coord = { + { 300.95, -74.43, 1001.52 }, + { 301.60, -77.81, 1001.52 } + } + local ignore = false + for k,v in pairs(ignore_coord) do + local distance = getDistanceBetweenCoords3d(X, Y, Z, v[1], v[2], v[3]) if distance <= 5 then - ammo_timer.last_ammo = k + ignore = true end - end --> by Benya + end + if not ignore then + ammo_timer.last_ammo = "" + for k, v in pairs(ammo) do + local distance = getDistanceBetweenCoords3d(X, Y, Z, v.x, v.y, v.z) + if distance <= 5 then + ammo_timer.last_ammo = k + end + end --> by Benya + end end ScoresAndPings = {} function sampev.onUpdateScoresAndPings(data)