landsandboat/scripts/commands/addallweaponskills.lua

40 lines
1,015 B
Lua

-----------------------------------
-- func: addallweaponskills
-- desc: Adds all learned weaponskills to the given target. If no target then to the current player.
-----------------------------------
---@type TCommand
local commandObj = {}
commandObj.cmdprops =
{
permission = 1,
parameters = 's'
}
local function error(player, msg)
player:printToPlayer(msg)
player:printToPlayer('!addallweaponskills (player)')
end
commandObj.onTrigger = function(player, target)
-- validate target
local targ
if target then
targ = GetPlayerByName(target)
if not targ then
error(player, string.format('Player named "%s" not found!', target))
return
end
else
targ = player
end
-- add all learned weaponskills
for _, wsUnlockId in pairs(xi.wsUnlock) do
targ:addLearnedWeaponskill(wsUnlockId)
end
player:printToPlayer(string.format('%s now has all learned weaponskills.', targ:getName()))
end
return commandObj