landsandboat/scripts/commands/setmentor.lua

43 lines
1.1 KiB
Lua

-----------------------------------
-- func: setmentor <MentorMode> <target>
-- desc: 0 = Not a mentor, 1 = Unlocked but inactive, 2 = Unlocked & flag on.
-----------------------------------
---@type TCommand
local commandObj = {}
commandObj.cmdprops =
{
permission = 1,
parameters = 'is'
}
local function error(player, msg)
player:printToPlayer(msg)
player:printToPlayer('!setmentor <mode> (player)')
player:printToPlayer('mode: 0 = Not a mentor, 1 = Unlocked but inactive.')
end
commandObj.onTrigger = function(player, mentorMode, target)
-- validate mode
if mentorMode == nil or mentorMode < 0 or mentorMode > 1 then
error(player, 'Invalid mode.')
return
end
-- validate target
local targ
if target == nil then
targ = player
else
targ = GetPlayerByName(target)
if targ == nil then
error(player, string.format('Player named "%s" not found!', target))
return
end
end
-- set mentor mode (bool)
targ:setMentor(mentorMode > 0)
end
return commandObj