2021-01-18 13:34:00 -05:00
|
|
|
-----------------------------------
|
2018-05-19 17:48:14 -04:00
|
|
|
-- func: setskill <skill name or ID> <skill level> <target>
|
|
|
|
|
-- desc: sets target's level of specified skill
|
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 = {}
|
2018-05-19 17:48:14 -04:00
|
|
|
|
2023-09-02 07:01:35 -04:00
|
|
|
commandObj.cmdprops =
|
2018-05-19 17:48:14 -04:00
|
|
|
{
|
|
|
|
|
permission = 1,
|
2023-08-28 21:02:28 -04:00
|
|
|
parameters = 'sis'
|
2018-05-19 17:48: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('!setskill <skill name or ID> <skill level> (player)')
|
2018-05-19 17:48:14 -04:00
|
|
|
end
|
|
|
|
|
|
2023-09-02 07:01:35 -04:00
|
|
|
commandObj.onTrigger = function(player, skillName, skillLV, target)
|
2022-11-04 10:44:34 -04:00
|
|
|
if skillName == nil then
|
2023-08-28 21:02:28 -04:00
|
|
|
error(player, 'You must specify a skill to set!')
|
2018-05-19 17:48:14 -04:00
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if skillLV == nil then
|
2023-08-28 21:02:28 -04:00
|
|
|
error(player, 'You must specify the new skill level to set.')
|
2018-05-19 17:48:14 -04:00
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
2021-04-01 15:10:15 -04:00
|
|
|
local skillID = tonumber(skillName) or xi.skill[string.upper(skillName)]
|
2020-02-19 21:40:57 -08:00
|
|
|
local targ
|
2018-05-19 17:48:14 -04:00
|
|
|
|
2022-10-23 17:59:41 -04:00
|
|
|
if
|
|
|
|
|
skillID == nil or
|
|
|
|
|
skillID == 0 or
|
|
|
|
|
(skillID > 12 and skillID < 25) or
|
|
|
|
|
skillID == 46 or
|
|
|
|
|
skillID == 47 or
|
|
|
|
|
skillID > 57
|
|
|
|
|
then
|
2023-08-28 21:02:28 -04:00
|
|
|
error(player, 'You must specify a valid skill.')
|
2018-05-19 17:48:14 -04:00
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if target == nil then
|
|
|
|
|
if player:getCursorTarget() == nil then
|
|
|
|
|
targ = player
|
|
|
|
|
else
|
|
|
|
|
if player:getCursorTarget():isPC() then
|
|
|
|
|
targ = player:getCursorTarget()
|
|
|
|
|
else
|
2023-08-28 21:02:28 -04:00
|
|
|
error(player, 'You must target a player or specify a name.')
|
2018-05-19 17:48:14 -04:00
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
else
|
2021-01-09 08:01:35 +02:00
|
|
|
targ = GetPlayerByName(target)
|
2018-05-19 17:48:14 -04:00
|
|
|
if targ == nil then
|
2023-12-09 23:54:00 +00:00
|
|
|
player:printToPlayer(string.format('Player named "%s" not found!', target))
|
2018-05-19 17:48:14 -04:00
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2024-08-25 12:01:53 -04:00
|
|
|
if not targ then
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
2022-10-23 10:54:18 -04:00
|
|
|
targ:setSkillLevel(skillID, skillLV * 10)
|
2021-05-04 12:28:34 -04:00
|
|
|
targ:messageBasic(xi.msg.basic.SKILL_REACHES_LEVEL, skillID, skillLV)
|
|
|
|
|
|
2018-05-19 17:48:14 -04:00
|
|
|
if targ ~= player then
|
2023-12-09 23:54:00 +00:00
|
|
|
player:printToPlayer(string.format('%s\'s new skillID \'%s\' Skill: %s', targ:getName(), skillName, (targ:getCharSkillLevel(skillID) / 10)..'.0'))
|
2018-05-19 17:48:14 -04:00
|
|
|
end
|
|
|
|
|
end
|
2023-09-02 07:01:35 -04:00
|
|
|
|
|
|
|
|
return commandObj
|