mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-30 20:41:41 +09:00
If this still breaks i guess no rcon ¯\_(ツ)_/¯
This commit is contained in:
@@ -235,7 +235,7 @@ local function run_custom_command(command)
|
|||||||
-- runs the command
|
-- runs the command
|
||||||
local success, err = pcall(data.callback,command,args)
|
local success, err = pcall(data.callback,command,args)
|
||||||
if not success then error(err) end
|
if not success then error(err) end
|
||||||
if err ~= commands.error and player ~= SERVER then player_return({'ExpGamingCore_Command.command-ran'},defines.textcolor.info) end
|
if err ~= commands.error then player_return({'ExpGamingCore_Command.command-ran'},defines.textcolor.info) end
|
||||||
logMessage(player.name,command,'Used command',args)
|
logMessage(player.name,command,'Used command',args)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ end
|
|||||||
-- @tparam[opt=nil] string test_type the type to test for if not given then it tests for nil
|
-- @tparam[opt=nil] string test_type the type to test for if not given then it tests for nil
|
||||||
-- @treturn boolean is v of type test_type
|
-- @treturn boolean is v of type test_type
|
||||||
function ExpLib.is_type(v,test_type)
|
function ExpLib.is_type(v,test_type)
|
||||||
return test_type and v and type(v) == test_type or not test_type and not v or false
|
return test_type and v and type(v) == test_type or not test_type and not v or false
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Compare types faster for faster validation of prams, including giving an error if incorrect
|
--- Compare types faster for faster validation of prams, including giving an error if incorrect
|
||||||
@@ -115,26 +115,35 @@ end
|
|||||||
function ExpLib.player_return(rtn,colour,player)
|
function ExpLib.player_return(rtn,colour,player)
|
||||||
colour = ExpLib.is_type(colour,'table') and colour or defines.textcolor[colour] ~= defines.color.white and defines.textcolor[colour] or defines.color[colour]
|
colour = ExpLib.is_type(colour,'table') and colour or defines.textcolor[colour] ~= defines.color.white and defines.textcolor[colour] or defines.color[colour]
|
||||||
player = player or game.player
|
player = player or game.player
|
||||||
local function returnWith(callback)
|
-- converts the value to a string
|
||||||
if ExpLib.is_type(rtn,'table') then
|
local returnAsString
|
||||||
-- test for: userdata, locale string, table with __tostring meta method, any other table
|
if ExpLib.is_type(rtn,'table') then
|
||||||
if ExpLib.is_type(rtn.__self,'userdata') then callback('Cant Display Userdata')
|
if ExpLib.is_type(rtn.__self,'userdata') then
|
||||||
elseif ExpLib.is_type(rtn[1],'string') and string.find(rtn[1],'.+[.].+') and not string.find(rtn[1],'%s') then callback(rtn)
|
-- value is userdata
|
||||||
elseif getmetatable(rtn) ~= nil and not tostring(rtn):find('table: 0x') then callback(tostring(rtn))
|
returnAsString = 'Cant Display Userdata'
|
||||||
else callback(table.tostring(rtn)) end
|
elseif ExpLib.is_type(rtn[1],'string') and string.find(rtn[1],'.+[.].+') and not string.find(rtn[1],'%s') then
|
||||||
-- test for: function
|
-- value is a locale string
|
||||||
elseif ExpLib.is_type(rtn,'function') then callback('Cant Display Functions')
|
returnAsString = rtn
|
||||||
-- else just call tostring
|
elseif getmetatable(rtn) ~= nil and not tostring(rtn):find('table: 0x') then
|
||||||
else callback(tostring(rtn)) end
|
-- value has a tostring meta method
|
||||||
end
|
returnAsString = tostring(rtn)
|
||||||
|
else
|
||||||
|
-- value is a table
|
||||||
|
returnAsString = table.tostring(rtn)
|
||||||
|
end
|
||||||
|
elseif ExpLib.is_type(rtn,'function') then
|
||||||
|
-- value is a function
|
||||||
|
returnAsString = 'Cant Display Functions'
|
||||||
|
else returnAsString = tostring(rtn) end
|
||||||
|
-- returns to the player or the server
|
||||||
if player then
|
if player then
|
||||||
-- allows any valid player identifier to be used
|
-- allows any valid player identifier to be used
|
||||||
player = Game.get_player(player)
|
player = Game.get_player(player)
|
||||||
if not player then error('Invalid Player given to player_return',2) end
|
if not player then error('Invalid Player given to player_return',2) end
|
||||||
-- plays a nice sound that is different to normal message sound
|
-- plays a nice sound that is different to normal message sound
|
||||||
player.play_sound{path='utility/scenario_message'}
|
player.play_sound{path='utility/scenario_message'}
|
||||||
returnWith(function(newRtn) player.print(newRtn,colour) end)
|
player.print(returnAsString,colour)
|
||||||
else returnWith(function(newRtn) rcon.print(newRtn) end) end
|
else rcon.print(returnAsString) end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Convert ticks to hours
|
--- Convert ticks to hours
|
||||||
|
|||||||
Reference in New Issue
Block a user