2021-01-18 13:34:00 -05:00
|
|
|
-----------------------------------
|
2016-08-09 19:05:15 -04:00
|
|
|
-- func: mp <amount> <player>
|
2016-01-16 01:26:33 -05:00
|
|
|
-- desc: Sets the GM or target players mana.
|
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 = 'is'
|
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('!mp <amount> (player)')
|
2020-02-19 21:40:57 -08:00
|
|
|
end
|
2017-08-06 12:44:08 -04:00
|
|
|
|
2023-09-02 07:01:35 -04:00
|
|
|
commandObj.onTrigger = function(player, mp, target)
|
2017-08-06 12:44:08 -04:00
|
|
|
-- validate target
|
2020-02-19 21:40:57 -08:00
|
|
|
local targ
|
2022-12-03 09:20:16 -05:00
|
|
|
local cursorTarget = player:getCursorTarget()
|
2020-08-04 17:53:57 -04:00
|
|
|
|
|
|
|
|
if target then
|
2021-01-09 08:01:35 +02:00
|
|
|
targ = GetPlayerByName(target)
|
2020-08-04 17:53:57 -04:00
|
|
|
if not targ 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-06 12:44:08 -04:00
|
|
|
end
|
2022-12-03 09:20:16 -05:00
|
|
|
elseif cursorTarget and not cursorTarget:isNPC() then
|
|
|
|
|
targ = cursorTarget
|
2020-08-04 17:53:57 -04:00
|
|
|
else
|
|
|
|
|
targ = player
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- validate amount
|
|
|
|
|
if mp == nil or tonumber(mp) == nil then
|
2023-08-28 21:02:28 -04:00
|
|
|
error(player, 'You must provide an amount.')
|
2020-08-04 17:53:57 -04:00
|
|
|
return
|
|
|
|
|
elseif mp < 0 then
|
2023-08-28 21:02:28 -04:00
|
|
|
error(player, 'Invalid amount.')
|
2020-08-04 17:53:57 -04:00
|
|
|
return
|
2017-08-06 12:44:08 -04:00
|
|
|
end
|
2020-03-19 18:41:42 -07:00
|
|
|
|
2017-08-06 12:44:08 -04:00
|
|
|
-- set mp
|
2020-08-04 17:53:57 -04:00
|
|
|
if targ:isAlive() then
|
2020-02-19 21:40:57 -08:00
|
|
|
targ:setMP(mp)
|
2020-08-04 17:53:57 -04:00
|
|
|
if targ:getID() ~= player:getID() then
|
2023-12-09 23:54:00 +00:00
|
|
|
player:printToPlayer(string.format('Set %s\'s MP to %i.', targ:getName(), targ:getMP()))
|
2016-01-16 01:26:33 -05:00
|
|
|
end
|
2017-08-06 12:44:08 -04:00
|
|
|
else
|
2023-12-09 23:54:00 +00:00
|
|
|
player:printToPlayer(string.format('%s is currently dead.', targ:getName()))
|
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
|