Fixed Jail and server.interface

This commit is contained in:
Cooldude2606
2018-11-09 17:57:02 +00:00
parent d8ca2e0c9a
commit 7c00cfcaaa
4 changed files with 13 additions and 10 deletions

View File

@@ -28,21 +28,21 @@ AdminGui.add_button('jail','utility/clock',{'ExpGamingAdmin.tooltip-jail'},funct
end)
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)
local player, by_player = Admin.valid_players(player,by_player)
if not player then return end
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),
description='There was a player jailed.',
['Player:']='<<inline>>'..player.name,
['By:']='<<inline>>'..by_player_name,
['By:']='<<inline>>'..by_player.name,
['Reason:']=reason
} end
Role.meta.last_jail = player.name
Server.interface(Role.unassign,true,player,Role.get(player),by_player_name)
Server.interface(Role.assign,true,player,'Jail',by_player_name)
Server.interface(Role.assign,true,player,'Jail',by_player.name)
Server.interface(Role.unassign,true,player,Role.get(player),by_player.name)
end
Admin.add_action('Jail',Admin.jail)

View File

@@ -222,7 +222,7 @@ function Server.interface(callback,use_thread,env,...)
local callback = table.remove(thread.data,1)
callback = is_type(callback,'function') and callback or loadstring(callback)
local env = table.remove(thread.data,1)
if is_type(env,'table') and env._env == true then
if is_type(env,'table') and not is_type(env.__self,'userdata') and env._env == true then
local success, err = Manager.sandbox(callback,env,unpack(thread.data))
if not success then error(err) end
return err
@@ -242,7 +242,7 @@ function Server.interface(callback,use_thread,env,...)
if err then return false, err end
_callback = rtn
end
if is_type(env,'table') and env._env == true then
if is_type(env,'table') and not is_type(env.__self,'userdata') and env._env == true then
local success, err = Manager.sandbox(_callback,env,...)
if not success then return success,err
else return success, unpack(err) end

View File

@@ -17,7 +17,7 @@ local playerInfo = function(player,frame)
end
local getPlayers = function()
local rtn = {{{r=233,g=63,b=233},'Admin',{}},{{r=255,g=159,b=27},'',{}}}
local rtn = {{{r=233,g=63,b=233},'Admin',{},true},{{r=255,g=159,b=27},'',{},false}}
for _,player in pairs(game.connected_players) do
if player.admin then table.insert(rtn[2][3],player)
else table.insert(rtn[1][3],player) end

View File

@@ -4,9 +4,12 @@ script.on_event(defines.events.on_role_change,self.update)
return function()
local rtn = {}
local default = {}
for _,role_name in pairs(Role.order) do
local role = Role.get(role_name)
table.insert(rtn,{role.colour,role.short_hand,role:get_players(true),role.not_reportable})
if role.is_default then default = {role.colour,role.short_hand,role:get_players(true),role.not_reportable}
else table.insert(rtn,{role.colour,role.short_hand,role:get_players(true),role.not_reportable}) end
end
table.insert(rtn,default)
return rtn
end