added module armoff & script auto unload is player not mafia

update
rubin 2 years ago
parent 51a6e57bc2
commit f3306caf69
  1. 156
      mafia-tools.lua

@ -14,10 +14,10 @@ function main()
lua_thread.create(script_update.main)
repeat wait(0) until sampGetCurrentServerName() ~= "SA-MP"
repeat wait(0) until sampGetCurrentServerName():find("Samp%-Rp.Ru") or sampGetCurrentServerName():find("SRP")
-- local server = getSampRpServerName()
-- if server == "" then
-- thisScript():unload()
-- end
local server = getSampRpServerName()
if server == "" then
thisScript():unload()
end
config.init()
lua_thread.create(timer_2min.loop)
lua_thread.create(ammo_timer.loop)
@ -31,6 +31,7 @@ function main()
lua_thread.create(mafiawar.loop)
lua_thread.create(mhcars.loop)
lua_thread.create(healme.loop)
lua_thread.create(armoff.loop)
sampRegisterChatCommand("int",function()
local int = getActiveInterior()
@ -136,42 +137,13 @@ menu.update = function()
}
end
-->> Список слов для открытия склада
local warelock_text = {}
warelock_text[#warelock_text+1] = {
title = ">> Добавить строку",
click = function(button, list, input, outs)
if button == 1 then
menu.show = { true, "edit", function(button, list, input, outs)
if button == 1 then
if #input > 0 then
local arr = split(input, " ")
if arr[1] ~= nil then
config.data.get_guns.warelock_text[#config.data.get_guns.warelock_text+1] = arr[1]
config.save(config.data)
end
end
end
menu.show = { true, "warelock_auto" }
end, "", "Введите слово для открытия склада!"}
else
menu.show = { true, "main" }
end
end
}
for i = 1, #config.data.get_guns.warelock_text do
warelock_text[#warelock_text+1] = {
title = config.data.get_guns.warelock_text[i],
click = function(button, list, input, outs)
if button == 1 then
table.remove(config.data.get_guns.warelock_text, i)
config.save(config.data)
menu.show = { true, "warelock_auto" }
else
menu.show = { true, "main" }
end
end
}
-- Список армофф айди
local armoff_list = ""
for i = 1, #config.data.armoff do
armoff_list = string.format("%s%s%s", armoff_list, (i == 1 and "" or " "), config.data.armoff[i])
end
if armoff_list == "" then
armoff_list = "нет"
end
menu.dialog = {
@ -468,13 +440,6 @@ menu.update = function()
menu.show = { true, "main" }
end
},
{ -->> Список слов для запросов
title = "{"..config.data.font.color1.."}"..">{ffffff} Список запросов на открытие склада\t",
click = function(button, list, input , outs)
if button ~= 1 then return end
menu.show = { true, "warelock_auto" }
end
},
{ -->> Список оружия
title = "{"..config.data.font.color1.."}"..">{ffffff} Список оружия\t",
click = function(button, list, input , outs)
@ -629,6 +594,26 @@ menu.update = function()
config.save(config.data)
end
},
{ -->> armoff
title = "{"..config.data.font.color1.."}"..">{ffffff} armoff на ID стрел\t"..armoff_list,
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
local arr = split(input, " ")
local new = {}
for i = 1, #arr do
if arr[i]:find("(%d+)") then
new[#new+1] = tonumber(arr[i]:match("(%d+)"))
end
end
config.data.armoff = new
config.save(config.data)
end
menu.show = { true, "main" }
end, armoff_list, "Введите ID стрел на которых нужно оффать броню\nВведите ID через пробел\nПример: 0 1 3"}
end
},
}
},
["edit"] = {
@ -764,10 +749,6 @@ menu.update = function()
},
}
},
["warelock_auto"] = {
settings = {title = "mafia-tools" ,style = 2 ,btn1 = "Выбрать" ,btn2 = "Назад" ,forward = "{ffffff}" ,backwards = "\n" ,score = false},
warelock_text
},
}
end
menu.show = { false, "main" }
@ -803,8 +784,52 @@ menu.loop = function()
end
end
-- HEALME
-- ARMOFF
armoff = {}
armoff.onServerMessage = function(color, message)
if message:find("Война за бизнес %{6AB1FF%}.+ %{FFFFFF%}пройдет в %{6AB1FF%}.+ %{FFFFFF%}| ID: %{6AB1FF%}(%d+)") then
armoff.id = tonumber(message:match("Война за бизнес %{6AB1FF%}.+ %{FFFFFF%}пройдет в %{6AB1FF%}.+ %{FFFFFF%}| ID: %{6AB1FF%}(%d+)"))
armoff.time = os.time()
end
end
armoff.loop = function()
armoff.id = -1
armoff.time = 0
while true do
wait(0)
for a = 0, 2304 do
if sampTextdrawIsExists(a) then
local x, y = sampTextdrawGetPos(a)
if math.ceil(x) == 87 and math.ceil(y) == 244 then
sampTextdrawGetString()
local text = sampTextdrawGetString(a)
if text:find("ID:_(%d+)") then
armoff.id = tonumber(text:match("ID:_(%d+)"))
armoff.time = os.time()
end
end
end
end
if os.time() - armoff.time < 3 and #config.data.armoff > 0 then
local result = false
for i = 1, #config.data.armoff do
if config.data.armoff[i] == armoff.id then
result = true
end
end
if result then
local arm = getCharArmour(PLAYER_PED)
if arm > 0 and (armoff.antiflood == nil or os.time() - armoff.antiflood > 3) then
armoff.antiflood = os.time()
antiflood.add("/armoff")
end
end
end
end
end
-- HEALME
healme = {}
healme.old_interior = -1
healme.sended = 0
@ -981,7 +1006,14 @@ mafiawar.onServerMessage = function(color, message)
end
end
mafiawar.onCreate3DText = function(id, color, position, distance, testLOS, attachedPlayerId, attachedVehicleId, text)
if text:find("Владелец") then
-- msg.add(string.format("%d", color))
-- msg.add(string.format("%s", text))
if color == 10289407 and text:find("Владелец") then
mafiawar.id = id
mafiawar.biz = true
end
if color == -356056833 and text:find("Продается") then
mafiawar.id = id
mafiawar.biz = true
end
@ -1107,6 +1139,9 @@ get_guns.onShowDialog = function(id, style, title, button1, button2, text)
config.data.stats.rank = rank
config.data.stats.frac = frac
config.save(config.data)
if not isPlayerInMafia() then
thisScript():unload()
end
end
if not get_guns.check_stats then
get_guns.check_stats = true
@ -1683,30 +1718,20 @@ config.default = {
key = { "VK_G" },
auto_get_guns = false,
warelock_auto = false,
warelock_text = {
"sklad",
"склад",
"wl",
"warelock",
"/warelock"
},
warelock_time = 5
},
stats = {
frac = "",
rank = 0
},
war = {
armoff = true,
armoff_id = { 0, 1, 4 }
},
armoff = { 0, 1, 4 },
mafiawar = {
auto = true,
id = 0,
wait = 600
},
chat_timing = {
key = { "VK_MENU", "VK_A" },
key = { "VK_MENU", "VK_H" },
auto = true
},
mhcars = {
@ -1803,6 +1828,7 @@ function sampev.onServerMessage(color, message)
invite_helper.onServerMessage(color, message)
mafiawar.onServerMessage(color, message)
mhcars.onServerMessage(color, message)
armoff.onServerMessage(color, message)
local res = processEvent(get_guns.onServerMessage, table.pack(color, message))
if res then
return table.unpack(res)

Loading…
Cancel
Save