add sborka
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
local PLUGIN = PLUGIN
|
||||
util.AddNetworkString("ixWhitelistMenuOpen")
|
||||
util.AddNetworkString("ixWhitelistMenuDataRequest")
|
||||
util.AddNetworkString("ixWhitelistMenuData")
|
||||
util.AddNetworkString("ixWhitelistMenuApply")
|
||||
|
||||
local function GetFactionData()
|
||||
local data = {}
|
||||
for k, v in pairs(ix.faction.indices) do
|
||||
if v.Podr and v.Spec and v.Ranks then
|
||||
data[k] = {
|
||||
name = v.name,
|
||||
Podr = v.Podr,
|
||||
Spec = v.Spec,
|
||||
Ranks = v.Ranks
|
||||
}
|
||||
end
|
||||
end
|
||||
return data
|
||||
end
|
||||
|
||||
net.Receive("ixWhitelistMenuDataRequest", function(_, client)
|
||||
if not PLUGIN:HasAccess(client) then
|
||||
return
|
||||
end
|
||||
|
||||
local players = {}
|
||||
for _, ply in ipairs(player.GetAll()) do
|
||||
if ply:Alive() and ply:GetCharacter() then
|
||||
table.insert(players, {
|
||||
steamID = ply:SteamID(),
|
||||
name = ply:Name()
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
net.Start("ixWhitelistMenuData")
|
||||
net.WriteTable(players)
|
||||
net.WriteTable(GetFactionData())
|
||||
net.Send(client)
|
||||
end)
|
||||
|
||||
net.Receive("ixWhitelistMenuApply", function(_, client)
|
||||
if not PLUGIN:HasAccess(client) then
|
||||
return
|
||||
end
|
||||
|
||||
local targetSteamID = net.ReadString()
|
||||
local factionID = net.ReadUInt(16)
|
||||
local podrID = net.ReadUInt(8)
|
||||
local specID = net.ReadUInt(8)
|
||||
local rankID = net.ReadUInt(8)
|
||||
|
||||
local target = nil
|
||||
for _, ply in ipairs(player.GetAll()) do
|
||||
if ply:SteamID() == targetSteamID then
|
||||
target = ply
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if not target or not target:GetCharacter() then
|
||||
client:Notify("Игрок не найден.")
|
||||
return
|
||||
end
|
||||
|
||||
local faction = ix.faction.indices[factionID]
|
||||
if not faction then
|
||||
client:Notify("Фракция не найдена.")
|
||||
return
|
||||
end
|
||||
|
||||
if not faction.Podr[podrID] then
|
||||
client:Notify("Подразделение не найдено.")
|
||||
return
|
||||
end
|
||||
|
||||
if not faction.Spec[specID] then
|
||||
client:Notify("Специализация не найдена.")
|
||||
return
|
||||
end
|
||||
|
||||
local targetRanks = (faction.Podr[podrID] and faction.Podr[podrID].ranks) or faction.Ranks
|
||||
if not (targetRanks and targetRanks[rankID]) then
|
||||
client:Notify("Звание не найдено.")
|
||||
return
|
||||
end
|
||||
|
||||
if faction.Spec[specID].podr ~= podrID then
|
||||
client:Notify("Специализация не соответствует подразделению.")
|
||||
return
|
||||
end
|
||||
|
||||
local char = target:GetCharacter()
|
||||
char:SetFaction(factionID)
|
||||
char:SetPodr(podrID)
|
||||
char:SetSpec(specID)
|
||||
char:SetRank(rankID)
|
||||
|
||||
-- Респавн игрока для применения изменений
|
||||
target:Spawn()
|
||||
|
||||
client:Notify("Роль назначена: " .. target:Name())
|
||||
target:Notify("Вам назначена новая роль!")
|
||||
end)
|
||||
Reference in New Issue
Block a user