set url test & added new request param

update
rubin 2 years ago
parent 031102f003
commit 8491561766
  1. 205
      mafia-tools.lua

@ -778,6 +778,9 @@ end
mhcars = {} mhcars = {}
mhcars.time = 0 mhcars.time = 0
mhcars.onServerMessage = function(color, message) mhcars.onServerMessage = function(color, message)
if message == " Вы не являетесь лидером/замом мафии" then
mhcars.time = os.time() + 1800
end
if message == " Задание уже начато" then if message == " Задание уже начато" then
mhcars.time = os.time() + 1800 mhcars.time = os.time() + 1800
end end
@ -800,21 +803,28 @@ mhcars.onServerMessage = function(color, message)
mhTimer = mhTimer + tonumber(p2) mhTimer = mhTimer + tonumber(p2)
end end
mhcars.time = os.time() + mhTimer - config.data.mhcars.offset_wait mhcars.time = os.time() + mhTimer - config.data.mhcars.offset_wait
request.send[#request.send + 1] = {
key = "mhcars",
second = mhTimer
}
request.wait = 0
end end
end --> by Richard_Holmes end --> by Richard_Holmes
end end
mhcars.loop = function() mhcars.loop = function()
while true do while true do
wait(0) wait(0)
if mhcars.time == 0 then if sampIsLocalPlayerSpawned() and isPlayerInMafia() and config.data.stats.rank >= 9 then
if mhcars.antiflood == nil or os.time() - mhcars.antiflood > 1 then if mhcars.time == 0 then
mhcars.antiflood = os.time() if mhcars.antiflood == nil or os.time() - mhcars.antiflood > 1 then
antiflood.send[#antiflood.send+1] = "/mhcars "..config.data.mhcars.gang mhcars.antiflood = os.time()
antiflood.add("/mhcars "..config.data.mhcars.gang)
end
end end
end if mhcars.time ~= 0 and os.time() > mhcars.time then
if mhcars.time ~= 0 and os.time() > mhcars.time then if antiflood.get() > config.data.mhcars.wait then
if antiflood.get() > config.data.mhcars.wait then sampSendChat("/mhcars "..config.data.mhcars.gang)
sampSendChat("/mhcars "..config.data.mhcars.gang) end
end end
end end
end end
@ -883,22 +893,31 @@ end
mafiawar.loop = function() mafiawar.loop = function()
while true do while true do
wait(0) wait(0)
if config.data.mafiawar.auto and mafiawar.biz then if sampIsLocalPlayerSpawned() and isPlayerInMafia() and config.data.stats.rank >= 6 then
if mafiawar.time == 0 then if config.data.mafiawar.auto and mafiawar.biz then
if mafiawar.antiflood == nil or os.time() - mafiawar.antiflood > 1 then if mafiawar.time == 0 then
mafiawar.antiflood = os.time() if mafiawar.antiflood == nil or os.time() - mafiawar.antiflood > 1 then
antiflood.send[#antiflood.send+1] = "/mafiawar "..config.data.mafiawar.id mafiawar.antiflood = os.time()
antiflood.send[#antiflood.send+1] = "/mafiawar "..config.data.mafiawar.id
end
end end
end if mafiawar.time ~= 0 and os.time() >= mafiawar.time then
if mafiawar.time ~= 0 and os.time() >= mafiawar.time then if antiflood.get() > config.data.mafiawar.wait then
if antiflood.get() > config.data.mafiawar.wait then sampSendChat("/mafiawar "..config.data.mafiawar.id)
sampSendChat("/mafiawar "..config.data.mafiawar.id) end
end end
end end
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 = {} get_guns = {}
get_guns.warehouse = false 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 if message:find("^ %d+/%d+ Матов | %d+/%d+ Аптечек") and os.time() - get_guns.check_warehouse_time < 2 then
return false return false
end end
if message:find("^ .+%[%d+%]: (.+)") then if message:find("^ .+%[%d+%]: (.+)") and color == 33357823 then
get_guns.messages[#get_guns.messages+1] = message:match("^ .+%[%d+%]: (.+)") get_guns.messages[#get_guns.messages+1] = message:match("^ .+%[%d+%]: (.+)")
end 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.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 end
if message:find("^ .+ открыл%(а%) склад с оружием$") and not message:find(getLocalPlayerNickname()) then if message:find("^ .+ закрыл%(а%) склад с оружием$") then
get_guns.warelock_send = {} get_guns.warehouse = false
if not message:find(getLocalPlayerNickname()) then
get_guns.warelock_send = {}
end
end end
if message == " Броня уже 100%" and get_guns.getgun then if message == " Броня уже 100%" and get_guns.getgun then
antiflood.send[#antiflood.send+1] = "/getgun" antiflood.send[#antiflood.send+1] = "/getgun"
@ -971,8 +998,12 @@ end
get_guns.onShowDialog = function(id, style, title, button1, button2, text) get_guns.onShowDialog = function(id, style, title, button1, button2, text)
if title == "Статистика персонажа" then if title == "Статистика персонажа" then
local frac, rank = text:match("Организация\t(.+).Ранг\t.+%[(.+)%]") local frac, rank = text:match("Организация\t(.+).Ранг\t.+%[(.+)%]")
if frac == nil then
frac, rank = text:match("Организация\t(.+).Ранг\t(.+).Работа")
end
if rank ~= nil then if rank ~= nil then
rank = rank:gsub("лидер", "10") rank = rank:gsub("Нет", 0)
rank = rank:gsub("лидер", 10)
rank = tonumber(rank) rank = tonumber(rank)
config.data.stats.rank = rank config.data.stats.rank = rank
config.data.stats.frac = frac config.data.stats.frac = frac
@ -1022,45 +1053,47 @@ get_guns.loop = function()
antiflood.send[#antiflood.send+1] = "/stats" antiflood.send[#antiflood.send+1] = "/stats"
end end
elseif not get_guns.check_warehouse then 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() get_guns.antiflood = os.time()
antiflood.send[#antiflood.send+1] = "/warehouse" antiflood.send[#antiflood.send+1] = "/warehouse"
end end
end end
if get_guns.enter_textdraw and isKeyCanBePressed() and isKeysPressed(config.data.get_guns.key) and not get_guns.getgun then if isPlayerInMafia() then
get_guns.start_get() if get_guns.enter_textdraw and isKeyCanBePressed() and isKeysPressed(config.data.get_guns.key) and not get_guns.getgun then
else get_guns.start_get()
if isKeysPressed(config.data.get_guns.key) and get_guns.getgun then else
msg.add("Выполняется взятие ганов") if isKeysPressed(config.data.get_guns.key) and get_guns.getgun then
msg.add("Выполняется взятие ганов")
end
end end
end if #get_guns.messages > 0 then
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
if config.data.get_guns.warelock_auto and not get_guns.warehouse and config.data.stats.rank >= 8 then local result = false
local result = false local text = split(get_guns.messages[1], " ")
local text = split(get_guns.messages[1], " ") for i = 1, #config.data.get_guns.warelock_text do
for i = 1, #config.data.get_guns.warelock_text do for p = 1, #text do
for p = 1, #text do if text[p] == config.data.get_guns.warelock_text[i] then
if text[p] == config.data.get_guns.warelock_text[i] then result = true
result = true end
end 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 end
if result then table.remove(get_guns.messages, 1)
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 end
table.remove(get_guns.messages, 1) if #get_guns.warelock_send > 0 then
end if get_guns.warelock_send[1][1] < os.time() then
if #get_guns.warelock_send > 0 then if get_guns.warelock_send[1][2] == get_guns.warehouse then
if get_guns.warelock_send[1][1] < os.time() then antiflood.send[#antiflood.send+1] = "/warelock"
if get_guns.warelock_send[1][2] == get_guns.warehouse then end
antiflood.send[#antiflood.send+1] = "/warelock" table.remove(get_guns.warelock_send, 1)
end end
table.remove(get_guns.warelock_send, 1)
end end
end end
end end
@ -1178,6 +1211,17 @@ antiflood.loop = function()
end end
end 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
mafia_checker = {} mafia_checker = {}
@ -1257,21 +1301,31 @@ request = {}
request.chat = {} request.chat = {}
request.send = {} request.send = {}
request.base = {} request.base = {}
request.warelock = false
request.loop = function() request.loop = function()
request.wait = 0 request.wait = 0
while true do while true do
wait(0) wait(0)
if os.time() - request.wait >= 5 then 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() request.wait = os.time()
local request_table = { local request_table = {
sender = getLocalPlayerNickname(), sender = getLocalPlayerNickname(),
server = getServerAddress(), server = getServerAddress(),
room = config.data.room, room = config.data.room,
send = request.send, send = request.send,
can_warelock = can_warelock,
request_warelock = request.warelock
rand = os.clock() rand = os.clock()
} }
request.send = {} 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) local result, text = pcall(openURL, url, os.tmpname(), true)
if result then if result then
local result = pcall(request.handler, text) local result = pcall(request.handler, text)
@ -1366,28 +1420,6 @@ ammo_timer.onServerMessage = function(color, message)
end end
end 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 if message:find(".+ заказал спавн транспорта через %d+ секунд%. С банка фракции снято %d+ вирт$") then
request.send[#request.send + 1] = { request.send[#request.send + 1] = {
key = "ffixcar", key = "ffixcar",
@ -1659,13 +1691,26 @@ function sampev.onSendPickedUpPickup(id)
["sf"] = {x = -2626.4050292969, y = 210.6088104248, z = 4.6033186912537}, ["sf"] = {x = -2626.4050292969, y = 210.6088104248, z = 4.6033186912537},
["lv"] = {x = 2158.3286132813, y = 943.17541503906, z = 10.371940612793} ["lv"] = {x = 2158.3286132813, y = 943.17541503906, z = 10.371940612793}
} }
ammo_timer.last_ammo = "" local ignore_coord = {
for k, v in pairs(ammo) do { 300.95, -74.43, 1001.52 },
local distance = getDistanceBetweenCoords3d(X, Y, Z, v.x, v.y, v.z) { 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 if distance <= 5 then
ammo_timer.last_ammo = k ignore = true
end 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 end
ScoresAndPings = {} ScoresAndPings = {}
function sampev.onUpdateScoresAndPings(data) function sampev.onUpdateScoresAndPings(data)

Loading…
Cancel
Save