mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-31 04:51:40 +09:00
Fixed warnings not logging to discord
This commit is contained in:
@@ -92,13 +92,15 @@ if config.player_reports then
|
|||||||
}
|
}
|
||||||
end)
|
end)
|
||||||
Event.add(Reports.events.on_report_removed,function(event)
|
Event.add(Reports.events.on_report_removed,function(event)
|
||||||
|
if event.batch ~= 1 then return end
|
||||||
local player_name = get_player_name(event)
|
local player_name = get_player_name(event)
|
||||||
emit_event{
|
emit_event{
|
||||||
title='Report Removed',
|
title='Reports Removed',
|
||||||
description='A player has a report removed',
|
description='A player has a report removed',
|
||||||
color=Colors.green,
|
color=Colors.green,
|
||||||
['Player:']='<inline>'..player_name,
|
['Player:']='<inline>'..player_name,
|
||||||
['By:']='<inline>'..event.removed_by_name
|
['By:']='<inline>'..event.removed_by_name,
|
||||||
|
['Amount:']='<inline>'..event.batch_count
|
||||||
}
|
}
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
@@ -118,13 +120,15 @@ if config.player_warnings then
|
|||||||
}
|
}
|
||||||
end)
|
end)
|
||||||
Event.add(Warnings.events.on_warning_removed,function(event)
|
Event.add(Warnings.events.on_warning_removed,function(event)
|
||||||
local player_name,by_player_name = get_player_name(event)
|
if event.batch ~= 1 then return end
|
||||||
|
local player_name = get_player_name(event)
|
||||||
emit_event{
|
emit_event{
|
||||||
title='Warning Removed',
|
title='Warnings Removed',
|
||||||
description='A player has a warning removed',
|
description='A player has a warning removed',
|
||||||
color=Colors.green,
|
color=Colors.green,
|
||||||
['Player:']='<inline>'..player_name,
|
['Player:']='<inline>'..player_name,
|
||||||
['By:']='<inline>'..by_player_name
|
['By:']='<inline>'..event.removed_by_name,
|
||||||
|
['Amount:']='<inline>'..event.batch_count
|
||||||
}
|
}
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -43,6 +43,8 @@ local Reports = {
|
|||||||
-- @tparam number player_index the player index of the player who has the report removed
|
-- @tparam number player_index the player index of the player who has the report removed
|
||||||
-- @tparam string reported_by_name the name of the player who made the removed report
|
-- @tparam string reported_by_name the name of the player who made the removed report
|
||||||
-- @tparam string removed_by_name the name of the player who removed the report
|
-- @tparam string removed_by_name the name of the player who removed the report
|
||||||
|
-- @tparam number batch_count the number of reports removed in this batch, always one when not a batch
|
||||||
|
-- @tparam number batch the index of this event in a batch, always one when not a batch
|
||||||
on_report_removed = script.generate_event_name()
|
on_report_removed = script.generate_event_name()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -159,13 +161,15 @@ end
|
|||||||
-- @tparam LuaPlayer player the player who is having the report removed from them
|
-- @tparam LuaPlayer player the player who is having the report removed from them
|
||||||
-- @tparam string reported_by_name the player who had the report
|
-- @tparam string reported_by_name the player who had the report
|
||||||
-- @tparam string removed_by_name the player who is clearing the report
|
-- @tparam string removed_by_name the player who is clearing the report
|
||||||
local function report_removed_event(player,reported_by_name,removed_by_name)
|
local function report_removed_event(player,reported_by_name,removed_by_name,batch,batch_count)
|
||||||
script.raise_event(Reports.events.on_report_removed,{
|
script.raise_event(Reports.events.on_report_removed,{
|
||||||
name = Reports.events.on_report_removed,
|
name = Reports.events.on_report_removed,
|
||||||
tick = game.tick,
|
tick = game.tick,
|
||||||
player_index = player.index,
|
player_index = player.index,
|
||||||
reported_by_name = reported_by_name,
|
reported_by_name = reported_by_name,
|
||||||
removed_by_name = removed_by_name
|
removed_by_name = removed_by_name,
|
||||||
|
batch_count = batch_count or 1,
|
||||||
|
batch = batch or 1
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -207,8 +211,10 @@ function Reports.remove_all(player,removed_by_name)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local ctn, total = 0, #reports
|
||||||
for reported_by_name,_ in pairs(reports) do
|
for reported_by_name,_ in pairs(reports) do
|
||||||
report_removed_event(player,reported_by_name,removed_by_name)
|
ctn = ctn + 1
|
||||||
|
report_removed_event(player, reported_by_name, removed_by_name, ctn, total)
|
||||||
end
|
end
|
||||||
|
|
||||||
user_reports[player.name] = nil
|
user_reports[player.name] = nil
|
||||||
|
|||||||
@@ -45,6 +45,8 @@ local Warnings = {
|
|||||||
-- @tparam string warning_by_name the name of the player who gave the warning
|
-- @tparam string warning_by_name the name of the player who gave the warning
|
||||||
-- @tparam string removed_by_name the name of the player who is removing the warning
|
-- @tparam string removed_by_name the name of the player who is removing the warning
|
||||||
-- @tparam number warning_count the new number of warnings that the player has
|
-- @tparam number warning_count the new number of warnings that the player has
|
||||||
|
-- @tparam number batch_count the number of warnings removed in this batch, always one when not a batch
|
||||||
|
-- @tparam number batch the index of this event in a batch, always one when not a batch
|
||||||
on_warning_removed = script.generate_event_name(),
|
on_warning_removed = script.generate_event_name(),
|
||||||
--- When a warning is added to a player, by the script
|
--- When a warning is added to a player, by the script
|
||||||
-- @event on_script_warning_added
|
-- @event on_script_warning_added
|
||||||
@@ -145,14 +147,16 @@ end
|
|||||||
-- @tparam string warning_by_name the name of the player who made the warning
|
-- @tparam string warning_by_name the name of the player who made the warning
|
||||||
-- @tparam string removed_by_name the name of the player who is doing the action
|
-- @tparam string removed_by_name the name of the player who is doing the action
|
||||||
-- @tparam number warning_count the number of warnings that the player how has
|
-- @tparam number warning_count the number of warnings that the player how has
|
||||||
local function warning_removed_event(player,warning_by_name,removed_by_name,warning_count)
|
local function warning_removed_event(player,warning_by_name,removed_by_name,warning_count,batch,batch_count)
|
||||||
script.raise_event(Warnings.events.on_warning_removed,{
|
script.raise_event(Warnings.events.on_warning_removed,{
|
||||||
name = Warnings.events.on_warning_removed,
|
name = Warnings.events.on_warning_removed,
|
||||||
tick = game.tick,
|
tick = game.tick,
|
||||||
player_index = player.index,
|
player_index = player.index,
|
||||||
warning_count = warning_count,
|
warning_count = warning_count,
|
||||||
warning_by_name = warning_by_name,
|
warning_by_name = warning_by_name,
|
||||||
removed_by_name = removed_by_name
|
removed_by_name = removed_by_name,
|
||||||
|
batch_count = batch_count or 1,
|
||||||
|
batch = batch or 1
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -189,7 +193,7 @@ function Warnings.clear_warnings(player,by_player_name)
|
|||||||
|
|
||||||
local warning_count = #warnings
|
local warning_count = #warnings
|
||||||
for n,warning in pairs(warnings) do
|
for n,warning in pairs(warnings) do
|
||||||
warning_removed_event(player,warning.by_player_name,by_player_name,warning_count-n)
|
warning_removed_event(player,warning.by_player_name,by_player_name,warning_count-n,n,warning_count)
|
||||||
end
|
end
|
||||||
|
|
||||||
user_warnings[player.name] = nil
|
user_warnings[player.name] = nil
|
||||||
|
|||||||
Reference in New Issue
Block a user