added invite helper & antiflood send cmd

update
rubin 2 years ago
parent e592bac721
commit b25d162925
  1. 129
      mafia-tools.lua

@ -22,6 +22,7 @@ function main()
lua_thread.create(request.loop)
lua_thread.create(menu.loop)
lua_thread.create(mafia_checker.loop)
lua_thread.create(antiflood.loop)
wait(-1)
end
@ -222,11 +223,11 @@ menu.update = function()
end
},
{ -->> Mafia Checker
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.."}".."Счетчик мафий на сервере и в стриме\t",
click = function(button, list, input , outs)
if button ~= 1 then return end
menu.show = { true, "main" }
end
},
{ -->> Рендер Mafia Checker
title = "{"..config.data.font.color1.."}"..">{ffffff} Показать на экране\t"..(config.data.mafia_checker.main and "вкл" or "выкл"),
@ -245,7 +246,53 @@ menu.update = function()
mafia_checker.setpos = true
menu.show = { true, "main" }
end
},
},
{ -->> Invite Helper
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.invite_helper.lvl,
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 and input:find("(%d+)") then
config.data.invite_helper.lvl = tonumber(input:match("(%d+)"))
config.save(config.data)
end
end
menu.show = { true, "main" }
end, config.data.invite_helper.lvl}
end
},
{ -->> Авто ранг вкл выкл
title = "{"..config.data.font.color1.."}"..">{ffffff} Устанавливать ранг автоматически\t"..(config.data.invite_helper.auto_rank and "вкл" or "выкл"),
click = function(button, list, input , outs)
if button ~= 1 then return end
config.data.invite_helper.auto_rank = not config.data.invite_helper.auto_rank
config.save(config.data)
menu.show = { true, "main" }
end
},
{ -->> Ранг по умолчанию
title = "{"..config.data.font.color1.."}"..">{ffffff} Установить ранг\t"..config.data.invite_helper.rank,
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 and input:find("(%d+)") then
config.data.invite_helper.rank = tonumber(input:match("(%d+)"))
config.save(config.data)
end
end
menu.show = { true, "main" }
end, config.data.invite_helper.rank}
end
},
}
},
["edit"] = {
@ -314,6 +361,52 @@ menu.loop = function()
end
end
-->> INVITE HELPER
invite_helper = {}
invite_helper.data = {}
invite_helper.onServerMessage = function(color, message)
if message:find("$ Вы приняли .+ в ") then
local name = message:match("$ Вы приняли (.+) в ")
if invite_helper.data[name] ~= nil then
antiflood.send[#antiflood.send+1] = invite_helper.data[name]
end
end
end
invite_helper.onSendCommand = function(cmd)
if cmd:lower():find("%/invite %d+ (%d+)") then
local id, rank = cmd:lower():match("%/invite (%d+) (%d+)")
local id = tonumber(id)
local result, name = getNickNameByPlayerId(id)
if result then
invite_helper.data[name] = "/giverank "..id.." "..rank
end
end
end
-->> ANTIFLOOD
antiflood = {}
antiflood.clock = 0
antiflood.set = function()
antiflood.clock = os.clock() * 1000
end
antiflood.get = function()
return (os.clock() * 1000 - antiflood.clock)
end
antiflood.send = {}
antiflood.loop = function()
while true do
wait(0)
if antiflood.get() > 1300 then
if #antiflood.send > 0 then
sampSendChat(antiflood.send[1])
table.remove(antiflood.send, 1)
antiflood.set()
end
end
end
end
-->> MAFIA CHECKER
mafia_checker = {}
mafia_checker.loop = function()
@ -631,6 +724,12 @@ config.default = {
main = false,
x = x2,
y = y2
},
invite_helper = {
lvl = 7,
auto_rank = true,
rank = 7,
key = "VK_I"
}
}
config.directory = string.format("%s\\moonloader\\config\\%s\\", getGameDirectory(), thisScript().name)
@ -695,6 +794,7 @@ end
function sampev.onServerMessage(color, message)
timer_2min.onServerMessage(color, message)
ammo_timer.onServerMessage(color, message)
invite_helper.onServerMessage(color, message)
end
function sampev.onSendPickedUpPickup(id)
local X, Y, Z = getCharCoordinates(PLAYER_PED)
@ -710,6 +810,14 @@ function sampev.onSendPickedUpPickup(id)
end
end --> by Benya
end
function sampev.onSendCommand(cmd)
antiflood.set()
invite_helper.onSendCommand(cmd)
end
function sampev.onSendChat(message)
antiflood.set()
end
-->> NEW FUNCTION
function getLocalPlayerNickname()
@ -793,6 +901,15 @@ function urlencode(str)
function (c) return string.format ("%%%02X", string.byte(c)) end)
return str
end
function getNickNameByPlayerId(id)
local result = false
local nick = ""
if sampIsPlayerConnected(id) then
nick = sampGetPlayerNickname(id)
result = true
end
return result, nick
end
-->> UPDATE MODULE
function openURL(url, fpath, message_off)

Loading…
Cancel
Save