2021-06-20 11:47:06 +03:00
|
|
|
-----------------------------------
|
|
|
|
|
-- func: !instance <instance_id>
|
|
|
|
|
-- desc: Load an instance and take you there
|
|
|
|
|
-----------------------------------
|
2024-08-25 10:54:45 -04:00
|
|
|
---@type TCommand
|
2023-09-02 07:01:35 -04:00
|
|
|
local commandObj = {}
|
2021-06-20 11:47:06 +03:00
|
|
|
|
2023-09-02 07:01:35 -04:00
|
|
|
commandObj.cmdprops =
|
2021-06-20 11:47:06 +03:00
|
|
|
{
|
|
|
|
|
permission = 1,
|
2023-08-28 21:02:28 -04:00
|
|
|
parameters = 'i'
|
2021-06-20 11:47:06 +03:00
|
|
|
}
|
|
|
|
|
|
2023-09-02 07:01:35 -04:00
|
|
|
local function error(player, msg)
|
2023-12-09 23:54:00 +00:00
|
|
|
player:printToPlayer(msg .. '\n!instance <instance_id>')
|
2021-06-20 11:47:06 +03:00
|
|
|
end
|
|
|
|
|
|
2023-09-02 07:01:35 -04:00
|
|
|
commandObj.onTrigger = function(player, instance_id)
|
2021-07-08 20:42:32 +03:00
|
|
|
if instance_id == nil then
|
2023-08-28 21:02:28 -04:00
|
|
|
error(player, 'You must provide an instance id')
|
2021-07-08 20:42:32 +03:00
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
2021-06-20 11:47:06 +03:00
|
|
|
local currentInstance = player:getInstance()
|
|
|
|
|
if currentInstance then
|
2023-12-09 23:54:00 +00:00
|
|
|
player:printToPlayer('It is not safe to use this command while inside an instance, try again after exiting.')
|
2021-06-20 11:47:06 +03:00
|
|
|
currentInstance:fail()
|
|
|
|
|
else
|
2023-12-09 23:54:00 +00:00
|
|
|
player:printToPlayer('Creating instance: ' .. instance_id)
|
2021-06-20 11:47:06 +03:00
|
|
|
player:createInstance(instance_id)
|
|
|
|
|
end
|
|
|
|
|
end
|
2023-09-02 07:01:35 -04:00
|
|
|
|
|
|
|
|
return commandObj
|