if SERVER then return end local MenuColor Color 102 204 255 255 local

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
if SERVER then return end
local MenuColor=Color(102,204,255,255)
local TextColor=Color(128,128,128,255)
surface.CreateFont("SkyDermaArial_I_17",{
font="Arial",
size=16,
weight=1000,
antialias=false,
italic=false,
})
function GetPlyAccess(ply)
if not ply:IsValid() then return end
return ply:GetNWBool("E2PowerAccess",false)
end
local function E2Power_BuildPanel(Panel)
Panel:ClearControls()
if not LocalPlayer():IsSuperAdmin() then
Panel.StateText=vgui.Create("DLabel")
Panel.StateText:SetColor(TextColor)
Panel.StateText:SetFont("SkyDermaArial_I_17")
Panel.StateText:SetText("Доступ запрещен\n\nВы не администратором сервера \n:(")
Panel.StateText:SizeToContents()
Panel:AddItem(Panel.StateText)
return
end
Panel.PlayerText=vgui.Create("DLabel")
Panel.PlayerText:SetColor(TextColor)
Panel.PlayerText:SetFont("SkyDermaArial_I_17")
Panel.PlayerText:SetText("Нажмите на имя игрока для открытия меню опций")
Panel.PlayerText:SizeToContents()
Panel:AddItem(Panel.PlayerText)
Panel.PlayerPanel=vgui.Create('DPanelList')
Panel.PlayerPanel:SetPadding(1)
Panel.PlayerPanel:SetSpacing(1)
Panel.PlayerPanel:SetAutoSize(true)
Panel:AddItem(Panel.PlayerPanel)
Panel.PlyList=vgui.Create('DListView')
Panel.PlyList:SetSize(100,150)
Panel.PlyList:AddColumn("Ник")
Panel.PlyList:AddColumn("Доступ"):SetFixedWidth(60)
Panel.PlyList:SetMultiSelect(false)
Panel.PlyList.LoadPlyList=function(self)
Panel.PlyList:Clear()
for _,ply in pairs(player.GetAll()) do
Panel.PlyList:AddLine(ply:Nick(),tostring(GetPlyAccess(ply)))
end
end
Panel.PlyList.OnClickLine=function(parent,line,isselected)
local Pl=line:GetValue(1)
local Stat=tobool(line:GetValue(2))
local ContMenu=DermaMenu()
if not Stat then
ContMenu:AddOption("Дать доступ",function()
RunConsoleCommand('e2power_give_access',Pl)
timer.Simple(0.2,function() Panel.PlyList.LoadPlyList() end)
end)
else
ContMenu:AddOption("Удалить доступ",function()
RunConsoleCommand('e2power_remove_access',Pl)
timer.Simple(0.2,function() Panel.PlyList.LoadPlyList() end)
end)
end
ContMenu:Open()
end
Panel.PlyList.LoadPlyList()
Panel.PlayerPanel:AddItem(Panel.PlyList)
Panel.RemoveAllBut=vgui.Create("DButton")
Panel.RemoveAllBut:SetText("Удалить доступ у всех игроков")
Panel.RemoveAllBut:SetSize(200,18)
Panel.RemoveAllBut.DoClick=function()
RunConsoleCommand('e2power_all_remove_access')
timer.Simple(0.2,function() Panel.PlyList.LoadPlyList() end)
end
Panel.PlayerPanel:AddItem(Panel.RemoveAllBut)
Panel.OptionText=vgui.Create("DLabel")
Panel.OptionText:SetColor(TextColor)
Panel.OptionText:SetFont("SkyDermaArial_I_17")
Panel.OptionText:SetText("Менеджер паролей")
Panel.OptionText:SizeToContents()
Panel:AddItem(Panel.OptionText)
Panel.FuncPanel=vgui.Create('DPanelList')
Panel.FuncPanel:SetPadding(1)
Panel.FuncPanel:SetSpacing(1)
Panel.FuncPanel:SetAutoSize(true)
Panel:AddItem(Panel.FuncPanel)
Panel.DisPassBut=vgui.Create("DButton")
Panel.DisPassBut:SetText("Очистить пароль")
Panel.DisPassBut:SetSize(200,18)
Panel.DisPassBut.DoClick=function()
RunConsoleCommand('e2power_disable_pass')
timer.Simple(0.2,function() Panel.PlyList.LoadPlyList() end)
end
Panel.FuncPanel:AddItem(Panel.DisPassBut)
Panel.GetPassBut=vgui.Create("DButton")
Panel.GetPassBut:SetText("Получить пароль")
Panel.GetPassBut:SetSize(200,18)
Panel.GetPassBut.DoClick=function()
RunConsoleCommand('e2power_get_pass')
end
Panel.FuncPanel:AddItem(Panel.GetPassBut)
Panel.PassBox=vgui.Create("DTextEntry")
Panel.PassBox:SetText("")
Panel.PassBox:SetSize(200,22)
Panel.PassBox:SelectAllOnFocus()
Panel.FuncPanel:AddItem(Panel.PassBox)
Panel.PassBut=vgui.Create("DButton")
Panel.PassBut:SetText("Установить новый пароль")
Panel.PassBut:SetSize(200,18)
Panel.PassBut.DoClick=function()
local NewPass=Panel.PassBox:GetValue()
if NewPass!="" then
RunConsoleCommand("e2power_set_pass",NewPass)
else
LocalPlayer():ChatPrint('[E2Power]: Пароль не может быть пустым')
end
end
Panel.FuncPanel:AddItem(Panel.PassBut)
Panel.GroupText=vgui.Create("DLabel")
Panel.GroupText:SetColor(TextColor)
Panel.GroupText:SetFont("SkyDermaArial_I_17")
Panel.GroupText:SetText("Нажмите на имя группы для открытия меню опций")
Panel.GroupText:SizeToContents()
Panel:AddItem(Panel.GroupText)
Panel.GroupPanel=vgui.Create('DPanelList')
Panel.GroupPanel:SetPadding(1)
Panel.GroupPanel:SetSpacing(1)
Panel.GroupPanel:SetAutoSize(true)
Panel:AddItem(Panel.GroupPanel)
Panel.GroupList=vgui.Create('DListView')
Panel.GroupList:SetSize(200,100)
Panel.GroupList:AddColumn("Имя группы")
Panel.GroupList:SetMultiSelect(false)
Panel.GroupList.LoadGroupList=function(self)
Panel.GroupList:Clear()
local Groups=util.JSONToTable(GetGlobalString("E2PowerGroupList")) or {}
for _,group in pairs(Groups) do
Panel.GroupList:AddLine(group)
end
end
Panel.GroupList.OnClickLine=function(parent,line,isselected)
local Group=line:GetValue(1)
local ContMenu=DermaMenu()
ontMenu:AddOption("Удалить группу",function()
RunConsoleCommand('e2power_remove_access_group',Group)
timer.Simple(0.2,function()
Panel.GroupList.LoadGroupList()
Panel.PlyList.LoadPlyList()
end)
end)
ContMenu:Open()
end
Panel.GroupList.LoadGroupList()
Panel.GroupPanel:AddItem(Panel.GroupList)
Panel.GroupBox=vgui.Create("DTextEntry")
Panel.GroupBox:SetText("")
Panel.GroupBox:SetSize(200,22)
Panel.GroupBox:SelectAllOnFocus()
Panel.GroupPanel:AddItem(Panel.GroupBox)
Panel.GroupBut=vgui.Create("DButton")
Panel.GroupBut:SetText("Создать группу")
Panel.GroupBut:SetSize(200,18)
Panel.GroupBut.DoClick=function()
local NewName=Panel.GroupBox:GetValue()
if NewName!="" then
RunConsoleCommand("e2power_give_access_group",NewName)
Panel.GroupBox:SetText("")
imer.Simple(0.2,function()
anel.GroupList.LoadGroupList()
Panel.PlyList.LoadPlyList()
end)
else
LocalPlayer():ChatPrint('Введите нормальное имя')
end
end
Panel.GroupPanel:AddItem(Panel.GroupBut)
if !E2Power_Panel then
E2Power_Panel=Panel
end
end
function E2Power_SMO()
if E2Power_Panel then
E2Power_BuildPanel(E2Power_Panel)
end
end
hook.Add("SpawnMenuOpen","E2Power_SpawnMenuOpen",E2Power_SMO)
hook.Add("PopulateToolMenu","E2Power_PopulateToolMenu",function()
spawnmenu.AddToolMenuOption("Utilities","E2Power","Menu","E2Power","","",E2Power_BuildPanel)
end)
for name,data in pairs(hook.GetTable()) do
if name=="UCLChanged" then
hook.Add("UCLChanged","E2Power_Update",E2Power_SMO)
break
end
end