Меню
Этот коммит содержится в:
родитель
0ef542ba8d
коммит
2afbfef90d
5 изменённых файлов: 135 добавлений и 2 удалений
|
|
@ -13,11 +13,13 @@ CAMI.RegisterPrivilege {
|
|||
|
||||
if SERVER then
|
||||
|
||||
AddCSLuaFile "permanent/cl_menu.lua"
|
||||
include "permanent/sv_data.lua"
|
||||
include "permanent/sv_entity.lua"
|
||||
include "permanent/sv_control.lua"
|
||||
|
||||
else
|
||||
|
||||
//
|
||||
include "permanent/cl_menu.lua"
|
||||
|
||||
end
|
||||
93
lua/permanent/cl_menu.lua
Обычный файл
93
lua/permanent/cl_menu.lua
Обычный файл
|
|
@ -0,0 +1,93 @@
|
|||
|
||||
local FRAME
|
||||
|
||||
function permanent.OpenMenu()
|
||||
|
||||
if IsValid(FRAME) then
|
||||
|
||||
FRAME:Remove()
|
||||
|
||||
end
|
||||
|
||||
FRAME = vgui.Create("DFrame")
|
||||
FRAME:SetSize(720, 480)
|
||||
FRAME:Center()
|
||||
FRAME:MakePopup()
|
||||
FRAME:SetSizable(false)
|
||||
FRAME:SetTitle("Permanent")
|
||||
FRAME:SetIcon("icon16/world.png")
|
||||
|
||||
local LIST = vgui.Create("DListView", FRAME)
|
||||
LIST:Dock(FILL)
|
||||
LIST:SetMultiSelect(false)
|
||||
LIST:AddColumn("ID")
|
||||
LIST:AddColumn("Class")
|
||||
LIST:AddColumn("Creator")
|
||||
LIST:AddColumn("Time")
|
||||
|
||||
LIST.OnRowSelected = function(panel, index, row)
|
||||
|
||||
local MENU = DermaMenu()
|
||||
|
||||
MENU:AddOption("Copy ID", function()
|
||||
|
||||
SetClipboardText(row:GetColumnText(1))
|
||||
|
||||
end):SetIcon("icon16/page_copy.png")
|
||||
|
||||
MENU:AddOption("Copy SteamID", function()
|
||||
|
||||
SetClipboardText(row:GetColumnText(3))
|
||||
|
||||
end):SetIcon("icon16/page_copy.png")
|
||||
|
||||
MENU:AddOption("Remove", function()
|
||||
|
||||
net.Start("Permanent", true)
|
||||
net.WriteUInt(2, 2)
|
||||
net.WriteEntity(row.ent)
|
||||
net.SendToServer()
|
||||
|
||||
end):SetIcon("icon16/page_delete.png")
|
||||
|
||||
MENU:Open()
|
||||
|
||||
end
|
||||
|
||||
local function populate()
|
||||
|
||||
for _, v in ipairs(ents.GetAll()) do
|
||||
|
||||
if !v:GetNWBool("IsPermanent") then continue end
|
||||
|
||||
LIST:AddLine(v:GetNWString("Permanent.ID"), v:GetClass(), v:GetNWString("Permanent.Creator"), os.date("%H:%M:%S - %d/%m/%Y", v:GetNWInt("Permanent.Time"))).ent = v
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
local BUTTONS = vgui.Create("DPanel", FRAME)
|
||||
BUTTONS:Dock(BOTTOM)
|
||||
BUTTONS:SetSize(0, 30)
|
||||
BUTTONS.Paint = function() end
|
||||
|
||||
local RESPAWN = vgui.Create("DButton", BUTTONS)
|
||||
RESPAWN:Dock(RIGHT)
|
||||
RESPAWN:DockMargin(0, 5, 5, 5)
|
||||
RESPAWN:SetSize(100, 0)
|
||||
RESPAWN:SetText("Respawn")
|
||||
RESPAWN:SetIcon("icon16/arrow_refresh.png")
|
||||
RESPAWN.DoClick = function()
|
||||
|
||||
net.Start("Permanent", true)
|
||||
net.WriteUInt(3, 2)
|
||||
net.SendToServer()
|
||||
|
||||
LIST:Clear()
|
||||
populate()
|
||||
|
||||
end
|
||||
|
||||
populate()
|
||||
|
||||
end
|
||||
35
lua/permanent/sv_control.lua
Обычный файл
35
lua/permanent/sv_control.lua
Обычный файл
|
|
@ -0,0 +1,35 @@
|
|||
|
||||
util.AddNetworkString("Permanent")
|
||||
|
||||
local function remove(ply)
|
||||
|
||||
local ent = net.ReadEntity()
|
||||
if !(IsValid(ent) && ent:GetNWBool("IsPermanent")) then return end
|
||||
|
||||
permanent.Remove(ent:GetNWString("Permanent.ID"))
|
||||
ent:Remove()
|
||||
|
||||
end
|
||||
|
||||
local function respawn(ply)
|
||||
|
||||
permanent.SpawnAll()
|
||||
|
||||
end
|
||||
|
||||
local operations = {}
|
||||
operations[0] = function() end
|
||||
operations[1] = function() end
|
||||
operations[2] = remove
|
||||
operations[3] = respawn
|
||||
|
||||
net.Receive("Permanent", function(len, ply)
|
||||
|
||||
if !CAMI.PlayerHasAccess(ply, "Permanent") then return end
|
||||
|
||||
local oper = net.ReadUInt(2)
|
||||
assert(operations[oper], "invalid operation")
|
||||
|
||||
operations[oper](ply)
|
||||
|
||||
end)
|
||||
|
|
@ -74,6 +74,7 @@ function permanent.Spawn(id)
|
|||
|
||||
ent:SetNWString("Permanent.ID", id)
|
||||
ent:SetNWString("Permanent.Creator", tbl.creator)
|
||||
ent:SetNWInt("Permanent.Time", tbl.time)
|
||||
ent:SetNWBool("IsPermanent", true)
|
||||
|
||||
return ent
|
||||
|
|
@ -82,6 +83,8 @@ end
|
|||
|
||||
function permanent.SpawnAll()
|
||||
|
||||
print("permanent.SpawnAll")
|
||||
|
||||
for _,v in ipairs(ents.GetAll()) do
|
||||
|
||||
if !v:GetNWBool("IsPermanent") then continue end
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ function TOOL:Reload()
|
|||
|
||||
if SERVER then return end
|
||||
|
||||
//
|
||||
permanent.OpenMenu()
|
||||
|
||||
end
|
||||
|
||||
|
|
|
|||
Загрузка…
Создание таблицы
Добавить ссылку
Сослаться в новой задаче