Added ExpGamingAdmin

This commit is contained in:
Cooldude2606
2018-08-26 17:28:18 +01:00
parent 121d983b08
commit 95233ebb40
48 changed files with 1410 additions and 604 deletions

View File

@@ -0,0 +1,149 @@
--- Desction <get from json>
-- @module ThisModule@X.Y.Z
-- @author <get from json>
-- @license <get from json>
-- @alais ThisModule
-- Module Require
local Admin = require('ExpGamingAdmin.AdminLib@^4.0.0')
local Server = require('ExpGamingCore.Server@^4.0.0')
local Ranking = require('ExpGamingCore.Ranking@^4.0.0')
local Game = require('FactorioStdLib.Game@^0.8.0')
local Color = require('FactorioStdLib.Color@^0.8.0')
local Sync -- ExpGamingCore.Sync@^4.0.0
-- so it can be used during on_init
local take_action = 8 -- below this number no action is taken, the first admin given warning jumps to this number
local remove_warnings_time = {}
local min_time_to_remove_warning = 18000 -- this is in ticks
-- Module Define
local module_verbose = false
local ThisModule = {
on_init=function()
if loaded_modules['ExpGamingCore.Sync@^4.0.0'] then Sync = require('ExpGamingCore.Sync@^4.0.0') end
if loaded_modules['ExpGamingAdmin.Reports@^4.0.0'] then
take_action = take_action + 1
table.insert(punishments,{'report',{'ExpGamingAdmin-Warnings@4-0-0.reported'},defines.text_color.med},take_action)
end
end,
on_post=function()
local highest = nil
for power,rank in pairs(Ranking.ranks) do
if not highest and not rank:allowed('no-report') then highest = power-1 end
local _power = power; if highest then _power = power-highest end
if rank:allowed('no-report') then remove_warnings_time[power] = 0
else remove_warnings_time[power] = min_time_to_remove_warning*_power end
end
end
}
-- Global Define
local global = global{}
-- Local Varibles
local punishments = {
{'nothing'},
{'nothing'},
{'nothing'},
{'nothing'},
{'nothing'},
{'message',{'ExpGamingAdmin-Warnings@4-0-0.message'},defines.text_color.info},
{'message',{'ExpGamingAdmin-Warnings@4-0-0.message'},defines.text_color.info},
{'message',{'ExpGamingAdmin-Warnings@4-0-0.kick-warn'},defines.text_color.med},
{'kick'},
{'message',{'ExpGamingAdmin-Warnings@4-0-0.temp-warn'},defines.text_color.high},
{'temp-ban'},
{'message',{'ExpGamingAdmin-Warnings@4-0-0.ban-warn'},defines.text_color.high},
{'message',{'ExpGamingAdmin-Warnings@4-0-0.last-warn'},defines.text_color.crit},
{'ban'}
}
-- Function Define
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>'
return player, by_player_name
end
local function give_punishment(player,by_player,reason)
local player, by_player_name = valid_players(player,by_player)
local warnings = Admin.get_warnings(player)
local punishment = punishments[warnings]
local reason = reason or 'No Other Reason'
if not punishment or 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)
Admin.report(player,'<server>',reason)
elseif punishment[1] == 'kick' then
global.actions[player.name] = actions.kick
Admin.kick(player,by_player,'Too Many Warnings: '..warnings-(take_action-1)..' Also: '..reason)
elseif punishment[1] == 'temp-ban' then
Admin.temp_ban(player,by_player,'Too Many Warnings: '..warnings-(take_action-1)..' Also: '..reason)
elseif punishment[1] == 'ban' then
global.actions[player.name] = actions.ban
Admin.ban(player,by_player,'Too Many Warnings: '..warnings-(take_action-1)..' Also: '..reason)
end
end
function Admin.get_warnings(player)
local player = Game.get_player(player)
return global[player.name] or 0
end
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 = Game.get_player(by_player) and take_action or min or 0
local warnings = Admin.get_warnings(player)
if warnings < min then warnings = min end
warnings = warnings+1
global[player.name] = warnings
if warnings > take_action then
player_return({'ExpGamingAdmin-Warnings@4-0-0.warning-given-by',by_player_name},defines.text_color.info,player)
game.print({'ExpGamingAdmin-Warnings@4-0-0.player-warning',player.name,by_player_name,reason})
end
give_punishment(player,by_player,reason)
end
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
global[player.name]=0
if not no_emit and Sync then
Sync.emit_embeded{
title='Player Clear',
color=Color.to_hex(defines.text_color.low),
description='A player had their warnings cleared.',
['Player:']='<<inline>>'..player.name,
['By:']='<<inline>>'..by_player_name,
}
end
end
-- Event Handlers Define
script.on_event(defines.events.on_tick,function(event)
if (game.tick % min_time_to_remove_warning) == 0 then
for name,warnings in pairs(global) do
if warnings > 0 then
local rank = Ranking.get_rank(name)
local time_to_remove = remove_warnings_time[rank.power]
if (game.tick % time_to_remove) == 0 then
global[name]=warnings-1
if global.warnings[name] > 5 then
player_return({'ExpGamingAdmin-Warnings@4-0-0.remove-warn',global[name],tick_to_display_format(time_to_remove)},defines.text_color.low,name)
end
end
end
end
end
end)
-- Module Return
return ThisModule

View File

@@ -0,0 +1,11 @@
[ExpGamingAdmin-Warnings-4-0-0]
warning-given-by=This Warnings Was Given By: __1__
player-warning=__1__ was given a warning by __2__ reason: __3__
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.

View File

@@ -0,0 +1,10 @@
[ExpGamingAdmin-Warnings-4-0-0]
warning-given-by=This warning was given by: __1__
player-warning=__1__ was given a warning by __2__ for: __3__
remove-warn=One of your warnings expired. You have __1__ warnings left, next warning will be removed in __2__
message=You are currently being warned by the system. These will continue until you cease and desist.
reported=You have been reported to the admins by the system. Further action may be taken if you do not cease and desist.
kick-warn=This is your last warning before you get kicked. The system will automatically kick you if you do not cease and desist.
temp-warn=This is your last warning before you get temporary banned. The system will automatically ban you if you do not cease and desist.
ban-warn=WARNING: This is your last warning before you get BANNED. The system will automatically BAN you if you do not cease and desist.
last-warn=WARNING: This is your last warning before you get PERMANENTLY BANNED. The system will automatically PERMANENTLY BAN you if you do not cease and desist.

View File

@@ -0,0 +1,11 @@
[ExpGamingAdmin-Warnings-4-0-0]
warning-given-by=This Warnings Was Given By: __1__
player-warning=__1__ was given a warning by __2__ reason: __3__
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.

View File

@@ -0,0 +1,11 @@
[ExpGamingAdmin-Warnings-4-0-0]
warning-given-by=Deze waarschuwing is gegeven door: __1__
player-warning=__1__ is gewaarschuwd door __2__ met de reden: __3__
temp-ban=__1__ is verbannen door __2__ en is gejailed tot de volgende reset.
remove-warn=Een waarschuwing is verlopen. Je hebt nu nog maar __1__ waarschuwing, volgende waarschuwing verloopt in __2__
message=Je ontvangt waarschuwingen door het systeem. Deze waarschuwingen stoppen niet tot je stopt met wat je verkeerd doet.
reported=Je bent gerapporteerd aan de administrators door het systeem. Je zal bestraft worden als je niet stopt met wat je verkeerd doet.
kick-warn=WAARSCHUWING: Dit is je laatste waarschuwing voordat je gekickt wordt.
temp-warn=WAARSCHUWING: Dit is je laatste waarschuwing voordat je tijdelijk verbannen wordt.
ban-warn=WAARSCHUWING: Dit is je laatste waarschuwing voordat je permanent verbannen wordt.
last-warn=DIT IS JE LAATSTE WAARSCHUWING. Het systeem zal je automatisch VERBANNEN als je niet stopt met wat je verkeerd doet.

View File

@@ -0,0 +1,10 @@
[ExpGamingAdmin-Warnings-4-0-0]
warning-given-by=Den här varningen gavs av: __1__
player-warning=__1__ var tillfälligt bannlyst av __2__ och kommer att förbli i fängelset tills nästa återställning (reset)
remove-warn=En av dina varningar har gått ut. Du har __1__ varning kvar, nästa varning kommer at tas bort om __2__
message=Du får för nuvarande varningar av systemet. De kommer fortsätta tills du upphör med överträdelsen.
reported= Du har blivit rapporterad till administrationen av systemet. Mer påföljd kan komma att tas om du inte upphör med överträdelsen.
kick-warn=Det här är din sista varning innan du blir sparkad. Systemet kommer att automatisk sparka dig om du inte upphör med överträdelsen
temp-warn=Det här är din sista varning innan du blir tillfälligt bannlyst. Systemet kommer att automatiskt bannlysa dig om du inte upphör överträdelsen
ban-warn=VARNING: Det här är din sista varning innan du blir bannlyst. Systemet kommer att automatisk bannlysa dig om du inte upphör med överträdelsen.
last-warn=VARNING: Det här är din sista varning innan du blir permanent bannlyst. Systemet kommer att automatiskt permanent bannlysa dig om du inte upphör med överträdelsen.

View File

@@ -0,0 +1,28 @@
{
"name": "Warnings",
"version": "4.0.0",
"type": "Submodule",
"description": "Adds a warning system into the admin set which can be used by admins and the script.",
"location": "<blank>",
"keywords": [
"Warning",
"Admin",
"ExpGaming",
"Report",
"Kick",
"Punishments",
"Ban"
],
"author": "<blank>",
"contact": "<blank>",
"license": "<blank>",
"dependencies": {
"ExpGamingAdmin.AdminLib": "^4.0.0",
"ExpGamingCore.Server": "^4.0.0",
"ExpGamingCore.Ranking": "^4.0.0",
"FactorioStdLib.Game": "^0.8.0",
"FactorioStdLib.Color": "^0.8.0",
"ExpGamingAdmin.Reports": "?^4.0.0",
"ExpGamingCore.Sync": "?^4.0.0"
}
}