nut.command.add("plysetclass", {
adminOnly = true,
syntax = "<string name> <string faction> <string class>",
onRun = function(client, arguments)
local target = nut.command.findPlayer(client, arguments[1])
local name = table.concat(arguments, " ", 2)
local group = arguments[3]
if (!group) then
for k, v in ipairs(nut.class.list) do
return client:notify(Format("Доступные подклассы: %s [%s]", v, k))
end
end
local tChar = target:getChar()
if (IsValid(target) and tChar) then
local faction = nut.faction.teams[name]
if (!faction) then
for k, v in ipairs(nut.faction.indices) do
if (nut.util.stringMatches(L(v.name, client), name)) then
faction = v
break
end
end
end
if (faction) then
tChar.vars.faction = faction.uniqueID
tChar:setFaction(faction.index)
if (faction.onTransfered) then
faction:onTransfered(target)
end
tChar:setClass(group)
for k, v in ipairs(player.GetHumans()) do
nut.util.notifyLocalized("cChangeFaction", v, client:Name(), target:Name(), L(faction.name, v))
end
else
return "@invalidFaction"
end
end
end
})