2021-01-18 13:34:00 -05:00
|
|
|
-----------------------------------
|
2020-08-18 14:00:14 -04:00
|
|
|
-- func: setmod
|
|
|
|
|
-- desc: Sets the specified modifier to the specified value on the cursor target or player
|
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 = {}
|
|
|
|
|
|
|
|
|
|
commandObj.cmdprops =
|
2020-08-18 14:00:14 -04:00
|
|
|
{
|
|
|
|
|
permission = 1,
|
2023-08-28 21:02:28 -04:00
|
|
|
parameters = 'sis'
|
2020-08-18 14:00:14 -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('!setmod <modifier> <amount> (optional target)')
|
2020-08-18 14:00:14 -04:00
|
|
|
end
|
|
|
|
|
|
2023-09-02 07:01:35 -04:00
|
|
|
commandObj.onTrigger = function(player, modifier, amount, target)
|
2020-09-13 17:07:26 -04:00
|
|
|
if not modifier or not amount then
|
2023-08-28 21:02:28 -04:00
|
|
|
error(player, 'Must specify modifier and amount. ')
|
2020-09-13 17:00:18 -04:00
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
2021-04-01 15:10:15 -04:00
|
|
|
local modID = tonumber(modifier) or xi.mod[string.upper(modifier)]
|
2020-08-18 14:00:14 -04:00
|
|
|
if not modID then
|
2023-08-28 21:02:28 -04:00
|
|
|
error(player, 'No valid modifier found. ')
|
2020-08-18 14:00:14 -04:00
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if target then
|
|
|
|
|
target = GetPlayerByName(target)
|
|
|
|
|
else
|
|
|
|
|
target = player:getCursorTarget()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if not target or target:isNPC() then
|
2023-08-28 21:02:28 -04:00
|
|
|
error(player, 'No valid target found. place cursor on a non-npc object or specify a player name. ')
|
2020-08-18 14:00:14 -04:00
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
2021-01-13 19:42:21 -05:00
|
|
|
local oldmod = target:getMod(modID)
|
|
|
|
|
target:setMod(modID, amount)
|
2023-12-09 23:54:00 +00:00
|
|
|
player:printToPlayer(string.format('Target name: %s (Target ID: %i) | Old %s modifier value: %i | New %s modifier value: %i', target:getName(), target:getID(), modifier, oldmod, modifier, amount))
|
2020-08-18 14:00:14 -04:00
|
|
|
end
|
2023-09-02 07:01:35 -04:00
|
|
|
|
|
|
|
|
return commandObj
|