Fixed Some Admin Commands

This commit is contained in:
Cooldude2606
2018-11-09 15:44:01 +00:00
parent cd48647640
commit f988380096
9 changed files with 15 additions and 15 deletions

View File

@@ -18,6 +18,7 @@ local Admin = {
if loaded_modules['ExpGamingCore.Server@^4.0.0'] then require('ExpGamingCore.Server@^4.0.0').add_module_to_interface('Admin','ExpGamingAdmin.AdminLib') end
end,
actions={},
action_functions={},
action_names={}
}
@@ -60,13 +61,13 @@ end
function Admin.add_action(action,callback)
verbose('Added admin action: '..action)
table.insert(Admin.action_names,action)
Admin.actions[string.lower(action)] = callback
Admin.acctions[string.lower(action)] = table.insert(Admin.action_names,action)
Admin.action_functions[string.lower(action)] = callback
end
function Admin.take_action(action,player,by_player,reason)
if Admin[action] then Admin[action](player,by_player,reason) end
if Admin.actions[string.lower(action)] then Admin.actions[string.lower(action)](player,by_player,reason) end
if Admin.action_functions[string.lower(action)] then Admin.action_functions[string.lower(action)](player,by_player,reason) end
end
function Admin.clear_player(player,by_player)

View File

@@ -11,7 +11,7 @@ commands.add_command('jail', 'Jails a player', {
}, function(event,args)
local player = args.player
local reason = args.reason
if Role.allowed(player,'no-report') then player_return{'ExpGamingAdmin.cant-report',args.player} return commands.error end
if Role.has_flag(player,'not_reportable') then player_return{'ExpGamingAdmin.cant-report',args.player} return commands.error end
if Admin.is_banned(player) then player_return{'ExpGamingCore_Command.cant-report-ban',args.player} return commands.error end
Admin.jail(player,event.player_index,reason)
end)
@@ -23,6 +23,6 @@ commands.add_command('unjail', 'Returns a player\'s old rank', {
['player']={true,'player'}
}, function(event,args)
local player = args.player
if Admin.is_banned(player) then player_return({'ExpGamingCore_Command.cant-report-ban',args.player}) return commands.error end
if Admin.is_banned(player,true) ~= 'jail' then player_return({'ExpGamingCore_Command.cant-report-ban',args.player}) return commands.error end
Server.interface(Role.revert,true,player,event.player_index,2)
end)

View File

@@ -13,7 +13,7 @@ commands.add_command('report', 'Reports a player', {
local player = args.player
local reason = args.reason
if Admin.is_banned(player) then player_return({'ExpGamingAdmin.cant-report-ban',args.player}) return commands.error end
if Role.allowed(player,'no-report') then player_return({'ExpGamingAdmin.cant-report',args.player}) return commands.error end
if Role.has_flag(player,'not_reportable') then player_return({'ExpGamingAdmin.cant-report',args.player}) return commands.error end
for _,report in pairs(global.addons.reports.reports) do if report[1] == _player.name then player_return({'ExpGamingAdmin.cant-report',args.player}) return commands.error end end
for _,report in pairs(global.addons.reports.varified) do if report[1] == _player.name then player_return({'ExpGamingAdmin.cant-report',args.player}) return commands.error end end
Admin.report(player,event.player_index,reason)

View File

@@ -10,6 +10,6 @@ commands.add_command('temp-ban', 'Temporarily ban a player', {
}, function(event,args)
local player = args.player
local reason = args.reason
if Admin.is_banned(player) then player_return({'ExpGamingAdmin.cant-report-ban',args.player}) return commands.error end
if Admin.is_banned(player) and Admin.is_banned(player,true) ~= 'jail' then player_return({'ExpGamingAdmin.cant-report-ban',args.player}) return commands.error end
Admin.temp_ban(player,event.player_index,reason)
end)

View File

@@ -12,7 +12,7 @@ commands.add_command('warn', 'Gives a player a warning', {
local player = args.player
local reason = args.reason
if Admin.is_banned(player) then player_return{'ExpGamingAdmin.cant-report-ban',args.player} return commands.error end
if Role.allowed(player,'no-report') then player_return{'ExpGamingAdmin.cant-report',args.player} return commands.error end
if Role.has_flag(player,'not_reportable') then player_return{'ExpGamingAdmin.cant-report',args.player} return commands.error end
Admin.give_warning(player,event.player_index,reason)
end)

View File

@@ -31,6 +31,7 @@ function Admin.jail(player,by_player,reason)
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 reason = Admin.create_reason(reason,by_player_name)
Admin.set_banned(player,'jail')
if Sync then Sync.emit_embeded{
title='Player Jail',
color=Color.to_hex(defines.textcolor.med),

View File

@@ -59,8 +59,7 @@ local function cheak_reports(player)
local player = Game.get_player(player)
if not player then return end
local reports = Admin.count_reports(player)
if reports >= reports_needed_for_jail and global.actions[player.name] ~= 'report-jail' and Role.get_highest(player).group.name ~= 'Jail' then
global.actions[player.name] = actions.report
if reports >= reports_needed_for_jail and Role.get_highest(player).group.name ~= 'Jail' then
Admin.jail(player,'<server>','Too many user reports. Contact an Admin to be unjailed.')
end
end
@@ -84,7 +83,7 @@ end
function Admin.report(player,by_player,reason)
local player, by_player_name = valid_players(player,by_player)
if not player or Role.allowed(player,'no-report') then return end
if not player or Role.has_flag(player,'not_reportable') then return end
if Admin.is_banned(by_player) or Role.has_flag(by_player,'is_jail') then return end
if Role.has_flag(by_player,'is_varified') then
global.varified[player.name] = global.varified[player.name] or {}

View File

@@ -81,12 +81,10 @@ local function give_punishment(player,by_player,reason)
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
@@ -114,7 +112,7 @@ 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
global[player.name]=nil
if not no_emit and Sync then
Sync.emit_embeded{
title='Player Clear',

View File

@@ -32,6 +32,7 @@ Role{
is_admin=true,
is_spectator=true,
is_donator=true,
not_reportable=true,
allow={}
}
Role{
@@ -43,6 +44,7 @@ Role{
is_admin=true,
is_spectator=true,
is_donator=true,
not_reportable=true,
allow={
['interface']=true,
['cheat-mode']=true
@@ -93,7 +95,6 @@ Role{
allow={
['go-to']=true,
['bring']=true,
['no-report']=true,
['set-home']=false,
['home']=false,
['return']=false,