added handler cmd

update
rubin 2 years ago
parent a7be8a1b2a
commit 75ca827d4c
  1. 69
      mafia-tools.lua

@ -248,26 +248,26 @@ menu.update = function()
end end
}, },
{ -->> Invite Helper { -->> Invite Helper
title = "{"..config.data.font.color1.."}".."Инвайт хелпер\t", title = "{"..config.data.font.color1.."}".."Инвайт хелпер\t",
click = function(button, list, input , outs) click = function(button, list, input , outs)
if button ~= 1 then return end if button ~= 1 then return end
menu.show = { true, "main" } menu.show = { true, "main" }
end end
}, },
{ -->> Минимальный лвл { -->> Минимальный лвл
title = "{"..config.data.font.color1.."}"..">{ffffff} Минимальный уровень\t"..config.data.invite_helper.lvl, title = "{"..config.data.font.color1.."}"..">{ffffff} Минимальный уровень\t"..config.data.invite_helper.lvl,
click = function(button, list, input , outs) click = function(button, list, input , outs)
if button ~= 1 then return end if button ~= 1 then return end
menu.show = { true, "edit", function(button, list, input, outs) menu.show = { true, "edit", function(button, list, input, outs)
if button == 1 then if button == 1 then
if #input > 0 and input:find("(%d+)") then if #input > 0 and input:find("(%d+)") then
config.data.invite_helper.lvl = tonumber(input:match("(%d+)")) config.data.invite_helper.lvl = tonumber(input:match("(%d+)"))
config.save(config.data) config.save(config.data)
end
end end
end menu.show = { true, "main" }
menu.show = { true, "main" } end, config.data.invite_helper.lvl}
end, config.data.invite_helper.lvl} end
end
}, },
{ -->> Авто ранг вкл выкл { -->> Авто ранг вкл выкл
title = "{"..config.data.font.color1.."}"..">{ffffff} Устанавливать ранг автоматически\t"..(config.data.invite_helper.auto_rank and "вкл" or "выкл"), title = "{"..config.data.font.color1.."}"..">{ffffff} Устанавливать ранг автоматически\t"..(config.data.invite_helper.auto_rank and "вкл" or "выкл"),
@ -381,12 +381,21 @@ invite_helper.onServerMessage = function(color, message)
end end
end end
invite_helper.onSendCommand = function(cmd) invite_helper.onSendCommand = function(cmd)
if cmd:lower():find("%/invite %d+ (%d+)") then if cmd:lower():find("%/invite %d+") then
local id, rank = cmd:lower():match("%/invite (%d+) (%d+)") local id, rank = cmd:lower():match("%/invite (%d+)"), config.data.invite_helper.rank
if cmd:lower():find("%/invite (%d+) (%d+)") then
id, rank = cmd:lower():match("%/invite (%d+) (%d+)")
end
local id = tonumber(id) local id = tonumber(id)
local result, name = getNickNameByPlayerId(id) local result, name = getNickNameByPlayerId(id)
if result then if result then
invite_helper.data[name] = "/giverank "..id.." "..rank local score = sampGetPlayerScore(id)
if score >= config.data.invite_helper.lvl then
invite_helper.data[name] = "/giverank "..id.." "..rank
else
addChatMessage(string.format("У игрока %s[%d] всего %d уровень. Нужен %d уровень!", name, id, score, config.data.invite_helper.lvl))
return true, false
end
end end
end end
end end
@ -414,7 +423,6 @@ antiflood.loop = function()
end end
end end
-->> MAFIA CHECKER -->> MAFIA CHECKER
mafia_checker = {} mafia_checker = {}
mafia_checker.loop = function() mafia_checker.loop = function()
@ -798,6 +806,19 @@ config.read = function()
end end
end end
events = {}
events.handler = function(handler, param)
for i = 1, #handler do
local result, pack = handler[i](table.unpack(param))
if result then
return pack
end
end
end
events.onSendCommand = {
invite_helper.onSendCommand
}
-->> EVENTS -->> EVENTS
function sampev.onServerMessage(color, message) function sampev.onServerMessage(color, message)
timer_2min.onServerMessage(color, message) timer_2min.onServerMessage(color, message)
@ -820,13 +841,15 @@ function sampev.onSendPickedUpPickup(id)
end end
function sampev.onSendCommand(cmd) function sampev.onSendCommand(cmd)
antiflood.set() antiflood.set()
invite_helper.onSendCommand(cmd) local result = events.handler(events.onSendCommand, { cmd })
if result ~= nil then
return result
end
end end
function sampev.onSendChat(message) function sampev.onSendChat(message)
antiflood.set() antiflood.set()
end end
-->> NEW FUNCTION -->> NEW FUNCTION
function getLocalPlayerNickname() function getLocalPlayerNickname()
return sampGetPlayerNickname(select(2, sampGetPlayerIdByCharHandle(PLAYER_PED))) return sampGetPlayerNickname(select(2, sampGetPlayerIdByCharHandle(PLAYER_PED)))

Loading…
Cancel
Save