2021-01-18 13:34:00 -05:00
|
|
|
-----------------------------------
|
2022-09-17 15:48:34 -04:00
|
|
|
-- func: addWeaponSkillPoints <slot> <points> (player)
|
2018-05-18 14:13:53 +09:00
|
|
|
-- desc: Adds weapon skill points to an equipped item.
|
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 =
|
2018-05-18 14:13:53 +09:00
|
|
|
{
|
|
|
|
|
permission = 1,
|
2023-08-28 21:02:28 -04:00
|
|
|
parameters = 'iis'
|
2018-05-18 14:13:53 +09: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('!addweaponskillpoints <slot main=0, sub=1, ranged=2> <points> (player)')
|
2018-05-18 14:13:53 +09:00
|
|
|
end
|
|
|
|
|
|
2023-09-02 07:01:35 -04:00
|
|
|
commandObj.onTrigger = function(player, slot, points, target)
|
2018-05-18 14:13:53 +09:00
|
|
|
-- validate slot
|
2021-04-01 15:10:15 -04:00
|
|
|
if slot < xi.slot.MAIN or slot > xi.slot.RANGED then
|
2023-08-28 21:02:28 -04:00
|
|
|
error(player, 'Slot out of range.')
|
2018-05-18 14:13:53 +09:00
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- validate points
|
2018-05-19 11:46:31 +09:00
|
|
|
if points < 0 then
|
2023-08-28 21:02:28 -04:00
|
|
|
error(player, 'Cannot add negative points.')
|
2018-05-18 14:13:53 +09:00
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- validate target
|
2018-05-19 11:46:31 +09:00
|
|
|
if target == nil then
|
2018-05-18 14:13:53 +09:00
|
|
|
target = player
|
|
|
|
|
else
|
2021-01-09 08:01:35 +02:00
|
|
|
target = GetPlayerByName(target)
|
2018-05-19 11:46:31 +09:00
|
|
|
if target == nil then
|
2023-08-28 21:02:28 -04:00
|
|
|
error(player, string.format('Player named "%s" not found!', target))
|
2018-05-18 14:13:53 +09:00
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local item = target:getStorageItem(0, 0, slot)
|
2018-05-19 11:46:31 +09:00
|
|
|
if item == nil then
|
2018-05-18 14:13:53 +09:00
|
|
|
local slotname = slot == 0 and 'main' or slot == 1 and 'sub' or slot == 2 and 'ranged'
|
|
|
|
|
error(player, string.format('No weapon equipped in %s slot.', slotname))
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- add weaponskill points
|
2018-05-19 11:46:31 +09:00
|
|
|
if target:addWeaponSkillPoints(slot, points) then
|
2023-12-09 23:54:00 +00:00
|
|
|
player:printToPlayer(string.format('Added %s weapon skill points to %s.', points, item:getName()))
|
2018-05-18 14:13:53 +09:00
|
|
|
else
|
2023-12-09 23:54:00 +00:00
|
|
|
player:printToPlayer(string.format('Could not add weapon skill points to %s.', item:getName()))
|
2018-05-18 14:13:53 +09:00
|
|
|
end
|
2020-03-19 18:41:42 -07:00
|
|
|
end
|
2023-09-02 07:01:35 -04:00
|
|
|
|
|
|
|
|
return commandObj
|