2023-09-07 08:18:40 -04:00
|
|
|
-----------------------------------
|
2021-04-11 07:05:25 -04:00
|
|
|
-- func: setcapacitypoints <amount> <player>
|
|
|
|
|
-- desc: Sets the target players job points count.
|
2023-09-07 08:18:40 -04:00
|
|
|
-----------------------------------
|
2024-08-25 10:54:45 -04:00
|
|
|
---@type TCommand
|
2023-09-02 07:01:35 -04:00
|
|
|
local commandObj = {}
|
2021-04-11 07:05:25 -04:00
|
|
|
|
2023-09-02 07:01:35 -04:00
|
|
|
commandObj.cmdprops =
|
2021-04-11 07:05:25 -04:00
|
|
|
{
|
|
|
|
|
permission = 1,
|
2023-08-28 21:02:28 -04:00
|
|
|
parameters = 'is'
|
2021-04-11 07:05:25 -04: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('!setcapacitypoints <amount> (player)')
|
2021-04-11 07:05:25 -04:00
|
|
|
end
|
|
|
|
|
|
2023-09-02 07:01:35 -04:00
|
|
|
commandObj.onTrigger = function(player, amount, target)
|
2021-04-11 07:05:25 -04:00
|
|
|
-- validate amount
|
|
|
|
|
if amount == nil or amount < 0 then
|
2023-08-28 21:02:28 -04:00
|
|
|
error(player, 'Invalid amount.')
|
2021-04-11 07:05:25 -04:00
|
|
|
return
|
|
|
|
|
elseif amount > 29999 then
|
|
|
|
|
amount = 29999
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- validate target
|
|
|
|
|
local targ
|
|
|
|
|
|
|
|
|
|
if target == nil then
|
|
|
|
|
targ = player
|
|
|
|
|
else
|
|
|
|
|
targ = GetPlayerByName(target)
|
|
|
|
|
|
|
|
|
|
if targ == nil then
|
2023-08-28 21:02:28 -04:00
|
|
|
error(player, string.format('Player named "%s" not found!', target))
|
2021-04-11 07:05:25 -04:00
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local jobNameByNum = {}
|
|
|
|
|
for k, v in pairs(xi.job) do
|
2022-10-23 10:54:18 -04:00
|
|
|
jobNameByNum[v] = k
|
2021-04-11 07:05:25 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- set capacity points
|
|
|
|
|
targ:setCapacityPoints(amount)
|
2023-12-09 23:54:00 +00:00
|
|
|
player:printToPlayer(string.format('%s now has %i capacity points on %s.', targ:getName(), amount, jobNameByNum[targ:getMainJob()]))
|
2021-04-11 07:05:25 -04:00
|
|
|
end
|
2023-09-02 07:01:35 -04:00
|
|
|
|
|
|
|
|
return commandObj
|