mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-27 19:45:22 +09:00
Merge branch 'release/5.1.1'
This commit is contained in:
@@ -101,11 +101,12 @@ Permission_Groups.new_group('Restricted')
|
||||
local trusted_time = 60*60*60*10 -- 10 hour
|
||||
local standard_time = 60*60*60*3 -- 3 hour
|
||||
local function assign_group(player)
|
||||
local current_group_name = player.permission_group and player.permission_group.name or 'None'
|
||||
if player.admin then
|
||||
Permission_Groups.set_player_group(player,'Admin')
|
||||
elseif player.online_time > trusted_time then
|
||||
elseif player.online_time > trusted_time and current_group_name == 'Trusted' then
|
||||
Permission_Groups.set_player_group(player,'Trusted')
|
||||
elseif player.online_time > standard_time then
|
||||
elseif player.online_time > standard_time and current_group_name == 'Guest' then
|
||||
Permission_Groups.set_player_group(player,'Standard')
|
||||
else
|
||||
Permission_Groups.set_player_group(player,'Guest')
|
||||
|
||||
@@ -523,8 +523,9 @@ end
|
||||
|
||||
-- logs command usage to file
|
||||
local function command_log(player,command,comment,params,raw,details)
|
||||
local player_name = player and player.name or '<Server>'
|
||||
game.write_file('log/commands.log',game.table_to_json{
|
||||
player_name=player.name,
|
||||
player_name=player_name,
|
||||
command_name=command.name,
|
||||
comment=comment,
|
||||
details=details,
|
||||
@@ -537,7 +538,11 @@ end
|
||||
-- @tparam command_event table passed directly from command event from the add_command function
|
||||
function Commands.run_command(command_event)
|
||||
local command_data = Commands.commands[command_event.name]
|
||||
local player = Game.get_player_by_index(command_event.player_index)
|
||||
-- player can be nil when it is the server
|
||||
local player
|
||||
if command_event.player_index and command_event.player_index > 0 then
|
||||
player = Game.get_player_by_index(command_event.player_index)
|
||||
end
|
||||
|
||||
-- checks if player is allowed to use the command
|
||||
local authorized, auth_fail = Commands.authorize(player,command_data.name)
|
||||
|
||||
@@ -8,11 +8,12 @@ Commands.new_command('admin-chat','Sends a message in chat that only admins can
|
||||
:add_tag('admin_only',true)
|
||||
:add_alias('ac')
|
||||
:register(function(player,message,raw)
|
||||
local pcc = player.chat_color
|
||||
local pcc = player and player.chat_color or {r=255,g=255,b=255}
|
||||
local player_name = player and player.name or '<Server>'
|
||||
local colour = string.format('%s,%s,%s',pcc.r,pcc.g,pcc.b)
|
||||
for _,return_player in pairs(game.connected_players) do
|
||||
if return_player.admin then
|
||||
return_player.print{'exp-commands.admin-chat-format',player.name,message,colour}
|
||||
return_player.print{'exp-commands.admin-chat-format',player_name,message,colour}
|
||||
end
|
||||
end
|
||||
return Commands.success -- prevents command complete message from showing
|
||||
|
||||
@@ -14,6 +14,7 @@ Commands.new_command('chelp','Searches for a keyword in all commands you are all
|
||||
:add_param('page',true,'integer') -- the keyword that will be looked for
|
||||
:add_defaults{keyword='',page=1}
|
||||
:register(function(player,keyword,page,raw)
|
||||
local player_index = player and player.index or 0
|
||||
-- if keyword is a number then treat it as page number
|
||||
if tonumber(keyword) then
|
||||
page = math.floor(tonumber(keyword))
|
||||
@@ -22,9 +23,9 @@ Commands.new_command('chelp','Searches for a keyword in all commands you are all
|
||||
-- gets a value for pages, might have result in cache
|
||||
local pages
|
||||
local found = 0
|
||||
if search_cache[player.index] and search_cache[player.index].keyword == keyword:lower() then
|
||||
pages = search_cache[player.index].pages
|
||||
found = search_cache[player.index].found
|
||||
if search_cache[player_index] and search_cache[player_index].keyword == keyword:lower() then
|
||||
pages = search_cache[player_index].pages
|
||||
found = search_cache[player_index].found
|
||||
else
|
||||
pages = {{}}
|
||||
local current_page = 1
|
||||
@@ -51,7 +52,7 @@ Commands.new_command('chelp','Searches for a keyword in all commands you are all
|
||||
})
|
||||
end
|
||||
-- adds the result to the cache
|
||||
search_cache[player.index] = {
|
||||
search_cache[player_index] = {
|
||||
keyword=keyword:lower(),
|
||||
pages=pages,
|
||||
found=found
|
||||
|
||||
@@ -56,10 +56,12 @@ Commands.new_command('interface','Sends an innovation to be ran and returns the
|
||||
end
|
||||
-- temp_env will index to interface_env and interface_modules if value not found
|
||||
local temp_env = setmetatable({},{__index=get_index})
|
||||
for name,callback in pairs(interface_callbacks) do
|
||||
-- loops over callbacks and loads the values returned
|
||||
local success, rtn = pcall(callback,player)
|
||||
temp_env[name]=rtn
|
||||
if player then -- player can be nil when it is the server
|
||||
for name,callback in pairs(interface_callbacks) do
|
||||
-- loops over callbacks and loads the values returned
|
||||
local success, rtn = pcall(callback,player)
|
||||
temp_env[name]=rtn
|
||||
end
|
||||
end
|
||||
-- sets the global metatable to prevent new values being made
|
||||
-- global will index to temp_env and new indexs saved to interface_sandbox
|
||||
|
||||
@@ -4,5 +4,6 @@ Commands.new_command('me','Sends an action message in the chat')
|
||||
:add_param('action',false) -- action that is done by the player, just text its meaningless
|
||||
:enable_auto_concat()
|
||||
:register(function(player,action,raw)
|
||||
game.print(string.format('* %s %s *',player.name,action),player.chat_color)
|
||||
local player_name = player and player.name or '<Server>'
|
||||
game.print(string.format('* %s %s *',player_name,action),player.chat_color)
|
||||
end)
|
||||
Reference in New Issue
Block a user