mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-27 11:35:22 +09:00
Added Reports
This commit is contained in:
@@ -10,8 +10,7 @@ Discord: https://discord.gg/r6dC2uK
|
||||
|
||||
Admin = Admin or {}
|
||||
|
||||
local function append_name(reason,player)
|
||||
local name = Game.get_player(player).name
|
||||
local function append_name(reason,name)
|
||||
local reason = reason or 'No Reason'
|
||||
if not string.find(string.lower(reason),string.lower(name)) then return reason..' - '..name
|
||||
else return reason end
|
||||
@@ -69,14 +68,14 @@ end)
|
||||
|
||||
function Admin.ban(player,by_player,reason)
|
||||
local player = Game.get_player(player)
|
||||
local _player = Game.get_player(by_player)
|
||||
local reason = append_name(reason,_player)
|
||||
local by_player_name = Game.get_player(by_player) and Game.get_player(by_player).name or '<server>'
|
||||
local reason = append_name(reason,by_player_name)
|
||||
discord_emit{
|
||||
title='Player Ban',
|
||||
color=Color.to_hex(defines.text_color.crit),
|
||||
description='There was a player banned.',
|
||||
['Player:']='<<inline>>'..player.name,
|
||||
['By:']='<<inline>>'.._player.name,
|
||||
['By:']='<<inline>>'..by_player_name,
|
||||
['Reason:']=reason
|
||||
}
|
||||
game.ban_player(player,reason)
|
||||
@@ -94,14 +93,14 @@ end)
|
||||
|
||||
function Admin.kick(player,by_player,reason)
|
||||
local player = Game.get_player(player)
|
||||
local _player = Game.get_player(by_player)
|
||||
local reason = append_name(reason,_player)
|
||||
local by_player_name = Game.get_player(by_player) and Game.get_player(by_player).name or '<server>'
|
||||
local reason = append_name(reason,by_player_name)
|
||||
discord_emit{
|
||||
title='Player Kick',
|
||||
color=Color.to_hex(defines.text_color.high),
|
||||
description='There was a player kicked.',
|
||||
['Player:']='<<inline>>'..player.name,
|
||||
['By:']='<<inline>>'.._player.name,
|
||||
['By:']='<<inline>>'..by_player_name,
|
||||
['Reason:']=reason
|
||||
}
|
||||
game.kick_player(player,reason)
|
||||
@@ -119,18 +118,18 @@ end)
|
||||
|
||||
function Admin.jail(player,by_player,reason)
|
||||
local player = Game.get_player(player)
|
||||
local _player = Game.get_player(by_player)
|
||||
local reason = append_name(reason,_player)
|
||||
local by_player_name = Game.get_player(by_player) and Game.get_player(by_player).name or '<server>'
|
||||
local reason = append_name(reason,by_player_name)
|
||||
discord_emit{
|
||||
title='Player Jail',
|
||||
color=Color.to_hex(defines.text_color.med),
|
||||
description='There was a player jailed.',
|
||||
['Player:']=player.name,
|
||||
['By:']='<<inline>>'.._player.name,
|
||||
['By:']='<<inline>>'..by_player_name,
|
||||
['Reason:']=reason
|
||||
}
|
||||
Ranking._presets().last_jail = player.name
|
||||
Ranking.give_rank(player,'Jail',_player)
|
||||
Ranking.give_rank(player,'Jail',by_player_name)
|
||||
end
|
||||
|
||||
Admin.go_to_btn = Gui.inputs.add{
|
||||
|
||||
@@ -8,28 +8,45 @@ Discord: https://discord.gg/r6dC2uK
|
||||
]]
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
|
||||
local report_to_warnings = 1
|
||||
local varified_to_warings = 3
|
||||
local report_to_warnings = 1 -- used in count_reports
|
||||
local varified_to_warings = 3 -- used in count_reports
|
||||
local reports_needed_for_jail = 10
|
||||
local take_action = 5 -- below this number no action is taken, the first admin given warning jumps to this number
|
||||
local min_time_to_remove_warning = 18000 -- this is in ticks
|
||||
local take_action = 8 -- below this number no action is taken, the first admin given warning jumps to this number
|
||||
local punishments = {
|
||||
{'nothing'},
|
||||
{'nothing'},
|
||||
{'nothing'},
|
||||
{'nothing'},
|
||||
{'nothing'},
|
||||
{'message'},
|
||||
{'message'},
|
||||
{'message-reported'},
|
||||
{'message-kick'},
|
||||
{'message',{'reports.message'},defines.text_color.info},
|
||||
{'message',{'reports.message'},defines.text_color.info},
|
||||
{'report',{'reports.reported'},defines.text_color.med},
|
||||
{'message',{'reports.kick-warn'},defines.text_color.med},
|
||||
{'kick'},
|
||||
{'message-temp-ban'},
|
||||
{'message',{'reports.temp-warn'},defines.text_color.high},
|
||||
{'temp-ban'},
|
||||
{'message-ban'},
|
||||
{'message-last-waring'},
|
||||
{'message',{'reports.ban-warn'},defines.text_color.high},
|
||||
{'message',{'reports.last-warn'},defines.text_color.crit},
|
||||
{'ban'}
|
||||
}
|
||||
|
||||
local actions = {
|
||||
none=0,
|
||||
report=1,
|
||||
jail=2,
|
||||
kick=3,
|
||||
temp=4,
|
||||
ban=5
|
||||
}
|
||||
|
||||
local function valid_players(player,by_player)
|
||||
local player = Game.get_player(player)
|
||||
local by_player_name = Game.get_player(by_player) and Game.get_player(by_player).name or '<server>'
|
||||
local rank = Ranking.get_rank(by_player_name)
|
||||
return player, by_player_name, rank
|
||||
end
|
||||
|
||||
local function _reports(reset)
|
||||
global.addons = not reset and global.addons or {}
|
||||
global.addons.reports = not reset and global.addons.reports or {warnings={},reports={},varified={},actions={}}
|
||||
@@ -38,49 +55,209 @@ end
|
||||
|
||||
local function get_warnings(player)
|
||||
local player = Game.get_player(player)
|
||||
return Admin._reports()[player.name] or 0
|
||||
return _reports().warnings[player.name] or 0
|
||||
end
|
||||
|
||||
local function report_message(player,by_player,reason)
|
||||
|
||||
local low_rank = Ranking.get_group('User').highest
|
||||
local high_rank = Ranking.get_group('Admin').lowest
|
||||
local player, by_player_name = valid_players(player,by_player)
|
||||
if not player then return end
|
||||
if _reports().actions[player.name] == actions.report then return end
|
||||
Ranking.print(low_rank,{'reports.low-print',player.name,med},defines.text_color.info,true)
|
||||
Ranking.print(high_rank,{'reports.high-print',player.name,by_player_name,reason},defines.text_color.med)
|
||||
discord_emit{
|
||||
title='Player Report',
|
||||
color=Color.to_hex(defines.text_color.med),
|
||||
description='There was a player reported.',
|
||||
['Player:']='<<inline>>'..player.name,
|
||||
['By:']='<<inline>>'..by_player_name,
|
||||
['Reason:']=reason
|
||||
}
|
||||
end
|
||||
|
||||
local function count_reports(player)
|
||||
-- counts the value of the reports
|
||||
local player = Game.get_player(player)
|
||||
if not player then return 0 end
|
||||
local _count = 0
|
||||
local data = _reports()
|
||||
if data.reports[player.name] then
|
||||
for _,report in pairs(data.reports[player.name]) do
|
||||
_count=_count+report_to_warnings
|
||||
end
|
||||
end
|
||||
if data.varified[player.name] then
|
||||
for _,report in pairs(data.varified[player.name]) do
|
||||
_count=_count+varified_to_warings
|
||||
end
|
||||
end
|
||||
return _count
|
||||
end
|
||||
|
||||
local function cheak_reports(player)
|
||||
-- jails a player if too many reports
|
||||
local player = Game.get_player(player)
|
||||
if not player then return end
|
||||
local reports = count_reports(player)
|
||||
if reports >= reports_needed_for_jail and _reports().actions[player.name] ~= 'report-jail' and Ranking.get_rank(player).group.name ~= 'Jail' then
|
||||
_reports().actions[player.name] = actions.report
|
||||
Admin.jail(player,'<server>','To many user reports. Contact an Admin to be unjailed.')
|
||||
discord_emit{
|
||||
title='Player Report Jail',
|
||||
color=Color.to_hex(defines.text_color.med),
|
||||
description='There was a player reported and jailed.',
|
||||
['Player:']=player.name,
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
local function give_punishment(player)
|
||||
-- gives a punishment based on the warnings, or nothing
|
||||
local function give_punishment(player,reason)
|
||||
local warnings = get_warnings(player)
|
||||
local punishment = punishments[warnings]
|
||||
local reason = reason or 'No Other Reason'
|
||||
if punishment[1] == 'nothing' then return
|
||||
elseif punishment[1] == 'message' then
|
||||
local message = punishment[2]
|
||||
local colour = punishment[3]
|
||||
player_return(message,colour,player)
|
||||
elseif punishment[1] == 'report' then
|
||||
local message = punishment[2]
|
||||
local colour = punishment[3]
|
||||
player_return(message,colour,player)
|
||||
report_message(player,'<server>',reason)
|
||||
elseif punishment[1] == 'kick' then
|
||||
_reports().actions[player.name] = actions.kick
|
||||
Admin.kick(player,'<server>','Too Many Warnings: '..warnings..' Also: '..reason)
|
||||
elseif punishment[1] == 'temp-ban' then
|
||||
_reports().actions[player.name] = actions.temp
|
||||
Admin.temp_ban(player,'<server>','Too Many Warnings: '..warnings..' Also: '..reason)
|
||||
elseif punishment[1] == 'ban' then
|
||||
_reports().actions[player.name] = actions.ban
|
||||
Admin.ban(player,'<server>','Too Many Warnings: '..warnings..' Also: '..reason)
|
||||
end
|
||||
end
|
||||
|
||||
function Admin.give_warning(player,by_player,reason)
|
||||
-- gives a waring, by_player is nil when done by script
|
||||
function Admin.give_warning(player,by_player,reason,min)
|
||||
local player, by_player_name = valid_players(player,by_player)
|
||||
if not player then return end
|
||||
local min = by_player_name and take_action or min or 0
|
||||
local warnings = get_warnings(player)
|
||||
if warnings < min then warnings = min end
|
||||
warnings = warnings+1
|
||||
_reports().warnings[player.name] = warnings
|
||||
give_punishment(player,reason)
|
||||
end
|
||||
|
||||
function Admin.report(player,by_player,reason)
|
||||
-- reports a user and adds to the right area
|
||||
local player, by_player_name = valid_players(player,by_player)
|
||||
if not player or Ranking.get_rank(player):allowed('no-report') then return end
|
||||
if rank:allowed('varified') then
|
||||
_reports.varified[player.name] = _reports.varified[player.name] or {}
|
||||
table.insert(_reports.varified,{by_player_name,reason})
|
||||
else
|
||||
_reports.reports[player.name] = _reports.reports[player.name] or {}
|
||||
table.insert(_reports.reports,{by_player_name,reason})
|
||||
end
|
||||
cheak_reports(player)
|
||||
end
|
||||
|
||||
function Admin.clear_warings(player,by_player)
|
||||
-- clears all warnings
|
||||
function Admin.clear_warings(player,by_player,no_emit)
|
||||
local player, by_player_name = valid_players(player,by_player)
|
||||
if not player then return end
|
||||
_reports().warnings[player.name]=0
|
||||
if not no_emit then
|
||||
discord_emit{
|
||||
title='Player Clear',
|
||||
color=Color.to_hex(defines.text_color.low),
|
||||
description='A player had there warnings cleared.',
|
||||
['Player:']='<<inline>>'..player.name,
|
||||
['By:']='<<inline>>'..by_player_name,
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
function Admin.clear_reports(player,by_player)
|
||||
-- clears any reports
|
||||
function Admin.clear_reports(player,by_player,no_emit)
|
||||
local player, by_player_name = valid_players(player,by_player)
|
||||
if not player then return end
|
||||
_reports().reports[player.name]={}
|
||||
_reports().varified[player.name]={}
|
||||
if not no_emit then
|
||||
discord_emit{
|
||||
title='Player Clear',
|
||||
color=Color.to_hex(defines.text_color.low),
|
||||
description='A player had there reports cleared.',
|
||||
['Player:']='<<inline>>'..player.name,
|
||||
['By:']='<<inline>>'..by_player_name,
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
function Admin.clear_player(player,by_player)
|
||||
-- clears, warnings, reports, jail
|
||||
local player, by_player_name = valid_players(player,by_player)
|
||||
if not player then return end
|
||||
Admin.clear_warings(player,by_player)
|
||||
Admin.clear_reports(player,by_player)
|
||||
_reports().actions[player.name]=actions.none
|
||||
if rank.group.name == 'Jail' then Ranking.revert(player,by_player) end
|
||||
discord_emit{
|
||||
title='Player Clear',
|
||||
color=Color.to_hex(defines.text_color.low),
|
||||
description='A player had there reports and warnings cleared.',
|
||||
['Player:']='<<inline>>'..player.name,
|
||||
['By:']='<<inline>>'..by_player_name,
|
||||
}
|
||||
end
|
||||
|
||||
function Admin.temp_ban(player,by_player,reason)
|
||||
-- jails a player and cant be unjailed and custom gui
|
||||
local function append_name(reason,name)
|
||||
local reason = reason or 'No Reason'
|
||||
if not string.find(string.lower(reason),string.lower(name)) then return reason..' - '..name
|
||||
else return reason end
|
||||
end
|
||||
local player, by_player_name = valid_players(player,by_player)
|
||||
if not player or Admin.is_banned(player) then return end
|
||||
_reports().actions[player.name] = actions.temp
|
||||
discord_emit{
|
||||
title='Player Temp-Ban',
|
||||
color=Color.to_hex(defines.text_color.med),
|
||||
description='There was a player jailed.',
|
||||
['Player:']='<<inline>>'..player.name,
|
||||
['By:']='<<inline>>'..by_player_name,
|
||||
['Reason:']=append_name(reason,by_player_name)
|
||||
}
|
||||
game.print({'reports.temp-ban',player,by_player_name},defines,text_color.info)
|
||||
Ranking._presets().last_jail = player.name
|
||||
Ranking.give_rank(player,'Jail',by_player_name)
|
||||
end
|
||||
|
||||
-- add an on_tick event to slowly remove warnings, faster for higher ranks
|
||||
function Admin.is_banned(player)
|
||||
local player=Game.get_player(player)
|
||||
local action = _reports().actions[player.name]
|
||||
if action == actions.temp then return 'temp'
|
||||
elseif action == actions.ban then return true
|
||||
else return false end
|
||||
end
|
||||
|
||||
-- add warnings to tree decon, then add warnings file to give warnings for diffrent actions
|
||||
Event.register(defines.events.on_tick,function(event)
|
||||
if not _reports().remove_warnings_time then
|
||||
_reports().remove_warnings_time = {}
|
||||
local highest = nil
|
||||
for power,rank in pairs(Ranking._rank) do
|
||||
if not highest and not rank:allowed('no-report') then highest = power+1 end
|
||||
local _power = power; if highest then _power = highest-power end
|
||||
if rank:allowed('no-report') then _reports().remove_warnings_time[power] = 0
|
||||
else _reports().remove_warnings_time[power] = min_time_to_remove_warning*_power end
|
||||
end
|
||||
end
|
||||
if (game.tick % min_time_to_remove_warning) == 0 then
|
||||
for name,warnings in pairs(_reports().warnings) do
|
||||
if warnings > 0 then
|
||||
local rank = Ranking.get_rank(name)
|
||||
local time_to_remove = _reports().remove_warnings_time[rank.power]
|
||||
if (game.tick % time_to_remove) == 0 then
|
||||
_reports().warnings[name]=warnings-1
|
||||
player_return({'reports.remove-warn',_reports().warnings[name],tick_to_displayer_format(time_to_remove)},defines,text_color.low,name)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
@@ -44,8 +44,9 @@ Event.register(-1,function(event)
|
||||
player_return({'tree-decon.player-print'},defines.text_color.crit,player)
|
||||
local rank = Ranking.get_group('Admin').lowest
|
||||
Ranking.print(rank,{'tree-decon.rank-print',player.name},defines.text_color.info)
|
||||
self.data.clear = game.tick + 10
|
||||
Admin.give_warning(player,'<server>','Trying To Decon The Base')
|
||||
end
|
||||
self.data.clear = game.tick + 10
|
||||
end
|
||||
end
|
||||
end):open()
|
||||
|
||||
54
Addons/Commands/admin.lua
Normal file
54
Addons/Commands/admin.lua
Normal file
@@ -0,0 +1,54 @@
|
||||
--[[
|
||||
Explosive Gaming
|
||||
|
||||
This file can be used with permission but this and the credit below must remain in the file.
|
||||
Contact a member of management on our discord to seek permission to use our code.
|
||||
Any changes that you may make to the code are yours but that does not make the script yours.
|
||||
Discord: https://discord.gg/r6dC2uK
|
||||
]]
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
|
||||
commands.add_command('report', 'Reports a player', {'player','reason',true}, function(event,args)
|
||||
local player = Game.get_player(args.player)
|
||||
local reason = args.reason
|
||||
if not player then player_return({'commands.invalid-player',args.player}) return commands.error end
|
||||
if Ranking.get_rank(player):allowed('no-report') or Admin.is_banned(player) then player_return({'reports.cant-report',args.player}) return commands.error end
|
||||
Admin.report(player,event.player_index,reason)
|
||||
end)
|
||||
|
||||
commands.add_command('give_warnings', 'Gives a player a warnings', {'player','reason',true}, function(event,args)
|
||||
local player = Game.get_player(args.player)
|
||||
local reason = args.reason
|
||||
if not player then player_return({'commands.invalid-player',args.player}) return commands.error end
|
||||
if Ranking.get_rank(player):allowed('no-report') or Admin.is_banned(player) then player_return({'reports.cant-report',args.player}) return commands.error end
|
||||
Admin.give_warning(player,event.player_index,reason)
|
||||
end)
|
||||
|
||||
commands.add_command('temp_ban', 'Temp Ban A Player', {'player','reason',true}, function(event,args)
|
||||
local player = Game.get_player(args.player)
|
||||
local reason = args.reason
|
||||
if not player then player_return({'commands.invalid-player',args.player}) return commands.error end
|
||||
if Admin.is_banned(player) then player_return({'reports.cant-report',args.player}) return commands.error end
|
||||
Admin.temp_ban(player,event.player_index,reason)
|
||||
end)
|
||||
|
||||
commands.add_command('clear_warings', 'Clears the warnings on a player', {'player'}, function(event,args)
|
||||
local player = Game.get_player(args.player)
|
||||
local reason = args.reason
|
||||
if not player then player_return({'commands.invalid-player',args.player}) return commands.error end
|
||||
Admin.clear_warings(player,event.player_index)
|
||||
end)
|
||||
|
||||
commands.add_command('clear_reports', 'Clears the reports from a player', {'player'}, function(event,args)
|
||||
local player = Game.get_player(args.player)
|
||||
local reason = args.reason
|
||||
if not player then player_return({'commands.invalid-player',args.player}) return commands.error end
|
||||
Admin.clear_reports(player,event.player_index)
|
||||
end)
|
||||
|
||||
commands.add_command('clear_player', 'Clears reports and reports and removes temp-ban', {'player'}, function(event,args)
|
||||
local player = Game.get_player(args.player)
|
||||
local reason = args.reason
|
||||
if not player then player_return({'commands.invalid-player',args.player}) return commands.error end
|
||||
Admin.clear_player(player,event.player_index)
|
||||
end)
|
||||
@@ -22,7 +22,9 @@ local function _players(_player,root_frame,state)
|
||||
local _players = state and game.players or game.connected_players
|
||||
for _,player in pairs(_players) do
|
||||
if player.name ~= _player.name then
|
||||
table.insert(players,player.name)
|
||||
if Admin.is_banned and Admin.is_banned(player) then else
|
||||
table.insert(players,player.name)
|
||||
end
|
||||
end
|
||||
end
|
||||
return players
|
||||
|
||||
@@ -20,7 +20,9 @@ local function _players(_player,root_frame,state)
|
||||
local _players = state and game.players or game.connected_players
|
||||
for _,player in pairs(_players) do
|
||||
if player.name ~= _player.name then
|
||||
table.insert(players,player.name)
|
||||
if Admin.is_banned and Admin.is_banned(player) then else
|
||||
table.insert(players,player.name)
|
||||
end
|
||||
end
|
||||
end
|
||||
return players
|
||||
|
||||
@@ -138,10 +138,14 @@ ranks['Admin']:edit('allow',false,{
|
||||
})
|
||||
ranks['Mod']:edit('allow',false,{
|
||||
['go-to']=true,
|
||||
['bring']=true
|
||||
['bring']=true,
|
||||
['no-report']=true
|
||||
})
|
||||
|
||||
ranks['Donator']:edit('allow',false,{
|
||||
|
||||
})
|
||||
ranks['Veteran']:edit('allow',false,{
|
||||
['tree-decon']=true
|
||||
})
|
||||
ranks['Member']:edit('allow',false,{
|
||||
|
||||
12
locale/en/reports.cfg
Normal file
12
locale/en/reports.cfg
Normal file
@@ -0,0 +1,12 @@
|
||||
[reports]
|
||||
low-print=__1__ has been reported by a user for: __2__
|
||||
high-print=__1__ has been reported by __2__ for: __3__
|
||||
cant-report=This player cant be reported.
|
||||
temp-ban=__1__ was temp-ban by __2__ and will remain in jail untill next reset
|
||||
remove-warn=You are had a warning Removed, you have __1__ warnings, next removed in __2__
|
||||
message=You Are Currently Reciving Warnings From The Script, This Will Continue Unless You Cease And Desist
|
||||
reported=You Have Been Reported To The Admins By The Script, Further Acction May Be Taken If You Do Not Cease And Desist.
|
||||
kick-warn=You Are On A Warning To Be KICKED, The Script Will Auto Kick If You Do Not Cease And Desist.
|
||||
temp-warn=You Are On A Warning To Be TEMP BANNED, The Script Will Auto Ban If You Do Not Cease And Desist.
|
||||
ban-warn=You Are On A Warning To Be BANNED, The Script Will Auto Ban If You Do Not Cease And Desist.
|
||||
last-warn=YOU ARE ON A LAST WARNING TO BE BANNED, THE SCRIPT WILL AUTO BAN IF YOU DO NOT CEASE AND DESIST.
|
||||
Reference in New Issue
Block a user