2021-01-18 13:34:00 -05:00
|
|
|
-----------------------------------
|
2016-08-09 19:05:15 -04:00
|
|
|
-- func: return <player>
|
2016-01-16 01:26:33 -05:00
|
|
|
-- desc: Warps GM or target player to their previous zone
|
2021-01-18 13:34:00 -05:00
|
|
|
-----------------------------------
|
2024-08-25 10:54:45 -04:00
|
|
|
---@type TCommand
|
2023-09-02 07:01:35 -04:00
|
|
|
local commandObj = {}
|
2016-01-16 01:26:33 -05:00
|
|
|
|
2023-09-02 07:01:35 -04:00
|
|
|
commandObj.cmdprops =
|
2016-01-16 01:26:33 -05:00
|
|
|
{
|
|
|
|
|
permission = 1,
|
2023-08-28 21:02:28 -04:00
|
|
|
parameters = 's'
|
2020-02-19 21:40:57 -08:00
|
|
|
}
|
2016-01-16 01:26:33 -05: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)
|
|
|
|
|
player:printToPlayer('!return (player)')
|
2020-02-19 21:40:57 -08:00
|
|
|
end
|
2017-08-07 11:19:50 -04:00
|
|
|
|
2023-09-02 07:01:35 -04:00
|
|
|
commandObj.onTrigger = function(player, target)
|
2017-08-07 11:19:50 -04:00
|
|
|
-- validate target
|
2020-02-19 21:40:57 -08:00
|
|
|
local targ
|
2022-10-30 09:13:30 -04:00
|
|
|
if target == nil then
|
2020-02-19 21:40:57 -08:00
|
|
|
targ = player
|
2016-01-16 01:26:33 -05:00
|
|
|
else
|
2021-01-09 08:01:35 +02:00
|
|
|
targ = GetPlayerByName(target)
|
2022-10-30 09:13:30 -04:00
|
|
|
if targ == nil then
|
2023-08-28 21:02:28 -04:00
|
|
|
error(player, string.format('Player named "%s" not found!', target))
|
2020-02-19 21:40:57 -08:00
|
|
|
return
|
2017-08-07 11:19:50 -04:00
|
|
|
end
|
2018-05-19 13:05:52 -04:00
|
|
|
end
|
2017-08-07 11:19:50 -04:00
|
|
|
|
|
|
|
|
-- get previous zone
|
2021-05-28 17:49:13 +03:00
|
|
|
local zoneId = targ:getPreviousZone()
|
2022-11-13 10:26:06 -05:00
|
|
|
if
|
|
|
|
|
zoneId == nil or
|
|
|
|
|
zoneId == xi.zone.UNKNOWN or
|
|
|
|
|
zoneId == xi.zone.RESIDENTIAL_AREA
|
|
|
|
|
then
|
2023-08-28 21:02:28 -04:00
|
|
|
error(player, 'Previous zone was a Mog House or there was a problem fetching the ID.')
|
2020-02-19 21:40:57 -08:00
|
|
|
return
|
2017-08-07 11:19:50 -04:00
|
|
|
end
|
2018-11-12 22:44:15 -05:00
|
|
|
|
2017-08-07 11:19:50 -04:00
|
|
|
-- zone target
|
2022-11-06 08:16:08 -05:00
|
|
|
targ:setPos(0, 0, 0, 0, zoneId)
|
2022-11-04 10:44:34 -04:00
|
|
|
if targ:getID() ~= player:getID() then
|
2023-12-09 23:54:00 +00:00
|
|
|
player:printToPlayer(string.format('%s was returned to zone %i.', targ:getName(), zoneId))
|
2016-01-16 01:26:33 -05:00
|
|
|
end
|
2020-03-19 18:41:42 -07:00
|
|
|
end
|
2023-09-02 07:01:35 -04:00
|
|
|
|
|
|
|
|
return commandObj
|