add
This commit is contained in:
@@ -92,8 +92,8 @@ function PANEL:Init()
|
||||
closeBtn.OnCursorExited = function(s) s:SetTextColor(COLOR_TEXT_DIM) end
|
||||
|
||||
self.nav = self:Add("Panel")
|
||||
self.nav:SetSize(450, 40)
|
||||
self.nav:SetPos(self:GetWide() - 520, 20)
|
||||
self.nav:SetSize(600, 40)
|
||||
self.nav:SetPos(self:GetWide() - 670, 20)
|
||||
|
||||
local function CreateNavBtn(text, view, x, activeColor)
|
||||
local btn = self.nav:Add("DButton")
|
||||
@@ -119,10 +119,25 @@ function PANEL:Init()
|
||||
|
||||
CreateNavBtn("Магазин", "shop", 0, COLOR_BASE)
|
||||
|
||||
if LocalPlayer():IsSuperAdmin() then
|
||||
CreateNavBtn("Панель", "panel", 160, Color(120, 0, 180))
|
||||
-- Всегда создаем кнопку "Панель", но скрываем для не-superadmin
|
||||
local panelBtn = CreateNavBtn("Панель", "panel", 160, Color(120, 0, 180))
|
||||
|
||||
local ply = LocalPlayer()
|
||||
if IsValid(ply) and (ply:IsSuperAdmin() or ply:GetUserGroup() == "superadmin") then
|
||||
panelBtn:SetVisible(true)
|
||||
else
|
||||
panelBtn:SetVisible(false)
|
||||
end
|
||||
|
||||
-- Проверка через 0.5 секунды на случай если данные еще загружаются
|
||||
timer.Simple(0.5, function()
|
||||
if not IsValid(panelBtn) or not IsValid(self) then return end
|
||||
local ply = LocalPlayer()
|
||||
if IsValid(ply) and (ply:IsSuperAdmin() or ply:GetUserGroup() == "superadmin") then
|
||||
panelBtn:SetVisible(true)
|
||||
end
|
||||
end)
|
||||
|
||||
self.content = self:Add("DScrollPanel")
|
||||
self.content:Dock(FILL)
|
||||
self.content:DockMargin(40, 100, 40, 40)
|
||||
|
||||
@@ -10,6 +10,41 @@ util.AddNetworkString("ixAdminShopPanelData")
|
||||
util.AddNetworkString("ixAdminShopPanelGivePoints")
|
||||
util.AddNetworkString("ixAdminShopPanelTakePoints")
|
||||
|
||||
local adminRanks = {
|
||||
["super admin"] = true,
|
||||
["superadmin"] = true,
|
||||
["projectteam"] = true,
|
||||
["teh.admin"] = true,
|
||||
["curator"] = true,
|
||||
["sudo-curator"] = true,
|
||||
["asist-sudo"] = true,
|
||||
["admin"] = true,
|
||||
["st.admin"] = true,
|
||||
["ivent"] = true,
|
||||
["st.event"] = true,
|
||||
["event"] = true,
|
||||
["disp"] = true,
|
||||
["assistant"] = true,
|
||||
["prem"] = true,
|
||||
["dsmoder"] = true
|
||||
}
|
||||
|
||||
local function IsAdminRank(rank)
|
||||
if not rank or rank == "user" then return false end
|
||||
|
||||
local lowerRank = string.lower(rank)
|
||||
|
||||
-- Check exact match in the provided list
|
||||
if adminRanks[lowerRank] then return true end
|
||||
|
||||
-- Keep generic string searches just in case
|
||||
if lowerRank == "founder" or lowerRank == "owner" or lowerRank == "manager" then return true end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
PLUGIN.IsAdminRank = IsAdminRank
|
||||
|
||||
function PLUGIN:Initialize()
|
||||
self.shopData = ix.data.Get("adminShop", {})
|
||||
end
|
||||
@@ -154,41 +189,6 @@ net.Receive("ixAdminShopRetrieve", function(len, client)
|
||||
end
|
||||
end)
|
||||
|
||||
local adminRanks = {
|
||||
["super admin"] = true,
|
||||
["superadmin"] = true,
|
||||
["projectteam"] = true,
|
||||
["teh.admin"] = true,
|
||||
["curator"] = true,
|
||||
["sudo-curator"] = true,
|
||||
["asist-sudo"] = true,
|
||||
["admin"] = true,
|
||||
["st.admin"] = true,
|
||||
["ivent"] = true,
|
||||
["st.event"] = true,
|
||||
["event"] = true,
|
||||
["disp"] = true,
|
||||
["assistant"] = true,
|
||||
["prem"] = true,
|
||||
["dsmoder"] = true
|
||||
}
|
||||
|
||||
local function IsAdminRank(rank)
|
||||
if not rank or rank == "user" then return false end
|
||||
|
||||
local lowerRank = string.lower(rank)
|
||||
|
||||
-- Check exact match in the provided list
|
||||
if adminRanks[lowerRank] then return true end
|
||||
|
||||
-- Keep generic string searches just in case
|
||||
if lowerRank == "founder" or lowerRank == "owner" or lowerRank == "manager" then return true end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
PLUGIN.IsAdminRank = IsAdminRank
|
||||
|
||||
-- Сбор данных игроков с доступом к магазину
|
||||
function PLUGIN:CollectPanelData()
|
||||
local playersData = {}
|
||||
|
||||
Reference in New Issue
Block a user