landsandboat/scripts/commands/mount.lua

44 lines
992 B
Lua
Raw Permalink Normal View History

---@type TCommand
local commandObj = {}
commandObj.cmdprops =
2020-02-29 00:40:44 +02:00
{
permission = 1,
parameters = 'sss'
}
2020-02-29 00:40:44 +02:00
local function error(player, msg)
player:printToPlayer(msg)
player:printToPlayer('!mount <mount ID> (player)')
2020-02-29 00:40:44 +02:00
end
commandObj.onTrigger = function(player, mount, target)
-- Default to Chocobo (0)
if mount == nil then
mount = 0
2020-02-29 00:40:44 +02:00
end
-- validate mount
2021-04-01 15:10:15 -04:00
mount = tonumber(mount) or xi.mount[string.upper(mount)]
if mount == nil or mount < 0 or mount >= xi.mount.MOUNT_MAX then
error(player, 'Invalid mount ID.')
2020-02-29 00:40:44 +02:00
return
end
-- validate target
local targ
if target == nil then
2020-02-29 00:40:44 +02:00
targ = player
else
targ = GetPlayerByName(target)
if targ == nil then
error(player, string.format('Player named "%s" not found!', target))
2020-02-29 00:40:44 +02:00
return
end
end
2026-02-19 22:48:02 -07:00
targ:addStatusEffect(xi.effect.MOUNTED, { power = mount, origin = player, silent = true })
2022-07-05 12:26:51 +03:00
end
return commandObj