From d17dec0265c87f693fca7d55c28d0b3af70886fd Mon Sep 17 00:00:00 2001 From: rubin Date: Mon, 6 Feb 2023 14:49:50 +0300 Subject: [PATCH] added getgun key G --- mafia-tools.lua | 95 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 93 insertions(+), 2 deletions(-) diff --git a/mafia-tools.lua b/mafia-tools.lua index 606df65..bf7d335 100644 --- a/mafia-tools.lua +++ b/mafia-tools.lua @@ -548,7 +548,42 @@ get_guns = {} get_guns.warehouse = false get_guns.isCanOpen = false get_guns.onServerMessage = function(color, message) + if message == "{FFFFFF} Вы можете использовать {00AB06}/getgun [ID игрока]{FFFFFF}, чтобы выдать оружие другим членам организации" then + if get_guns.getgun then + get_guns.stop = os.time() + return true, false + end + end + if message == " Вы не на складе оружия своей организации / у вас нет доступа!" or message == " Склад закрыт" then + if get_guns.getgun then + get_guns.stop = os.time() + end + end + if message:find("^ Склад .+ %{C42100%}закрыт") or message == " Склад закрыт" then + get_guns.warehouse = false + end + if message:find("^ Склад .+ %{00AB06%}открыт") or message == " Склад открыт" then + get_guns.warehouse = true + end + if message:find("^ .+%[%d+%]: (.+)") then + if config.data.stats.rank >= 8 then + end + end +end +get_guns.enter_textdrawId = -1 +get_guns.enter_textdraw = false +get_guns.onShowTextDraw = function(id, textdraw) + if textdraw.text:find("VEHICLE_ENTER_EXIT") then + get_guns.enter_textdrawId = id + get_guns.enter_textdraw = true + end +end +get_guns.onTextDrawHide = function(id) + if id == get_guns.enter_textdrawId then + get_guns.enter_textdrawId = -1 + get_guns.enter_textdraw = false + end end get_guns.onShowDialog = function(id, style, title, button1, button2, text) if title == "Статистика персонажа" then @@ -560,13 +595,31 @@ get_guns.onShowDialog = function(id, style, title, button1, button2, text) config.save(config.data) if not get_guns.check_stats then get_guns.check_stats = true + get_guns.antiflood = os.time() - 28 return true, false end end + if title == "Склад оружия" then + if get_guns.getgun then + if #get_guns.list > 0 then + sampSendDialogResponse(id,1,get_guns.list[1],"") + table.remove(get_guns.list, 1) + else + get_guns.getgun = false + end + return true, false + end + end end get_guns.loop = function() - get_guns.check_stats = false get_guns.antiflood = 0 + get_guns.check_stats = false + get_guns.check_warehouse = false + get_guns.warehouse = false + + get_guns.getgun = false + get_guns.stop = 0 + get_guns.list = {} while true do wait(0) if not get_guns.check_stats then @@ -574,8 +627,35 @@ get_guns.loop = function() get_guns.antiflood = os.time() antiflood.send[#antiflood.send+1] = "/stats" end + elseif not get_guns.check_warehouse then + if sampIsLocalPlayerSpawned() 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 wasKeyPressed(vkeys[config.data.get_guns.key]) and not get_guns.getgun then + get_guns.start_get() + end + if get_guns.getgun and get_guns.stop ~= 0 and os.time() - get_guns.stop > 1 then + get_guns.getgun = false + end + end +end +get_guns.start_get = function() + get_guns.list = {} + for i = 1, #config.data.get_guns.list do + if config.data.get_guns.list[i][2] > 0 then + for n = 1, config.data.get_guns.list[i][2] do + get_guns.list[#get_guns.list+1] = i - 1 + end end end + get_guns.getgun = true + get_guns.stop = 0 + antiflood.send[#antiflood.send+1] = "/getgun" +end +get_guns.check_warelock = function() + end @@ -1110,7 +1190,12 @@ function sampev.onShowDialog(id, style, title, button1, button2, text) return result end end - +function sampev.onShowTextDraw(id, data) + get_guns.onShowTextDraw(id, data) +end +function sampev.onTextDrawHide(id) + get_guns.onTextDrawHide(id) +end -->> NEW FUNCTION function getLocalPlayerNickname() return sampGetPlayerNickname(select(2, sampGetPlayerIdByCharHandle(PLAYER_PED))) @@ -1229,6 +1314,12 @@ function isPlayerInList(sender) end return result end +function isKeyCanBePressed() + if sampIsDialogActive() or sampIsChatInputActive() or sampIsCursorActive() or isSampfuncsConsoleActive() then + return false + end + return true +end -->> UPDATE MODULE function openURL(url, fpath, message_off)