add sborka
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
local PLUGIN = PLUGIN
|
||||
|
||||
net.Receive("ixKitSync", function()
|
||||
PLUGIN.kits = net.ReadTable()
|
||||
end)
|
||||
|
||||
net.Receive("ixKitMenu", function()
|
||||
if (IsValid(ix.gui.kitMenu)) then
|
||||
ix.gui.kitMenu:Remove()
|
||||
end
|
||||
|
||||
ix.gui.kitMenu = vgui.Create("DFrame")
|
||||
local menu = ix.gui.kitMenu
|
||||
menu:SetSize(500, 400)
|
||||
menu:SetTitle("Меню донатных наборов")
|
||||
menu:Center()
|
||||
menu:MakePopup()
|
||||
|
||||
local scroll = menu:Add("DScrollPanel")
|
||||
scroll:Dock(FILL)
|
||||
|
||||
for weaponClass, kit in pairs(PLUGIN.kits) do
|
||||
local panel = scroll:Add("DPanel")
|
||||
panel:Dock(TOP)
|
||||
panel:SetHeight(60)
|
||||
panel:DockMargin(5, 5, 5, 5)
|
||||
|
||||
local name = panel:Add("DLabel")
|
||||
name:SetText(kit.name)
|
||||
name:SetFont("ixMediumFont")
|
||||
name:SetTextColor(color_black)
|
||||
name:Dock(LEFT)
|
||||
name:DockMargin(10, 0, 0, 0)
|
||||
name:SizeToContents()
|
||||
|
||||
local btn = panel:Add("DButton")
|
||||
btn:SetText("Взять")
|
||||
btn:Dock(RIGHT)
|
||||
btn:SetWidth(100)
|
||||
btn:DockMargin(10, 10, 10, 10)
|
||||
|
||||
btn.DoClick = function()
|
||||
net.Start("ixKitClaim")
|
||||
net.WriteString(weaponClass)
|
||||
net.SendToServer()
|
||||
menu:Remove()
|
||||
end
|
||||
|
||||
-- Обработка отображения КД (простая версия)
|
||||
local character = LocalPlayer():GetCharacter()
|
||||
if (character) then
|
||||
local cooldowns = character:GetData("kit_cooldowns", {})
|
||||
local lastClaim = cooldowns[weaponClass] or 0
|
||||
local remaining = (lastClaim + kit.cooldown) - os.time()
|
||||
|
||||
if (remaining > 0) then
|
||||
btn:SetEnabled(false)
|
||||
btn:SetText(math.ceil(remaining / 60) .. " мин.")
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
Reference in New Issue
Block a user