Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function createAdminRequestUI(requests)
- if not IsValid(mainPanel) then
- -- Create the main panel using Xenin F4 framework
- surface.CreateFont("CustomFont", {
- font = "Arial",
- size = 15,
- weight = 400,
- antialias = true,
- shadow = false,
- })
- mainPanel = vgui.Create("XeninUI.Frame")
- mainPanel:SetSize(500 * SCALE_FACTOR, 600 * SCALE_FACTOR)
- local screenWidth, screenHeight = ScrW(), ScrH()
- mainPanel:SetPos(0, (screenHeight - mainPanel:GetTall()) / 2)
- mainPanel:SetTitle("Admin Requests")
- mainPanel:MakePopup()
- end
- local requestList = vgui.Create("DScrollPanel", mainPanel) -- Change DPanelList to DScrollPanel
- requestList:SetPos(10 * SCALE_FACTOR, 50 * SCALE_FACTOR + 12)
- requestList:SetSize(480 * SCALE_FACTOR, 520 * SCALE_FACTOR)
- -- Hide the scrollbar
- requestList.VBar.Paint = function() end
- requestList.VBar.btnUp.Paint = function() end
- requestList.VBar.btnDown.Paint = function() end
- requestList.VBar.btnGrip.Paint = function() end
- local unclaimedRequests = {}
- local function createOutlinedButton(parent, x, y, w, h, text, onClick)
- local button = vgui.Create("XeninUI.Button", parent)
- button:SetPos(x, y)
- button:SetSize(w, h)
- button:SetText(text)
- button:SetFont("CustomFont") -- Set custom font
- button:SetTextColor( Color(227, 227, 227))
- button.Paint = function(self, w, h)
- draw.RoundedBox(4, 0, 0, w, h, Color(29, 29, 29, 255))
- draw.RoundedBox(4, 1, 1, w - 2, h - 2, Color(54, 54, 54, 255))
- end
- button.DoClick = onClick
- return button
- end
- local buttonWidth = 280 * SCALE_FACTOR
- local buttonHeight = 30 * SCALE_FACTOR
- for i, requestData in ipairs(requests) do
- if not requestData.claimed then
- table.insert(unclaimedRequests, requestData)
- local requestPanel = vgui.Create("DPanel", requestList)
- requestPanel:SetSize(480 * SCALE_FACTOR, 100 * SCALE_FACTOR)
- requestPanel.Paint = function(self, w, h)
- draw.RoundedBox(4, 0, 0, w, h, Color(29, 29, 29, 255))
- draw.RoundedBox(4, 1, 1, w - 2, h - 2, Color(54, 54, 54, 255))
- end
- requestList:AddItem(requestPanel)
- -- Add user avatar
- local avatar = vgui.Create("AvatarImage", requestPanel)
- avatar:SetSize(64 * SCALE_FACTOR, 64 * SCALE_FACTOR)
- avatar:SetPos(10 * SCALE_FACTOR, 18 * SCALE_FACTOR)
- avatar:SetSteamID(requestData.steamID64, 64)
- -- Add user name
- local nameLabel = vgui.Create("DLabel", requestPanel)
- nameLabel:SetFont("CustomFont") -- Set custom font
- nameLabel:SetTextColor( Color(227, 227, 227))
- nameLabel:SetText(requestData.name)
- nameLabel:SetPos(84 * SCALE_FACTOR, 18 * SCALE_FACTOR)
- nameLabel:SizeToContents()
- -- Add request message
- local messageLabel = vgui.Create("DLabel", requestPanel)
- messageLabel:SetFont("CustomFont") -- Set custom font
- messageLabel:SetTextColor( Color(227, 227, 227))
- messageLabel:SetText(requestData.message)
- messageLabel:SetPos(84 * SCALE_FACTOR, 48 * SCALE_FACTOR)
- messageLabel:SizeToContents()
- -- Claim case button for each request
- local claimButton = vgui.Create("XeninUI.Button", requestPanel)
- claimButton:SetFont("CustomFont") -- Set custom font
- claimButton:SetTextColor( Color(227, 227, 227))
- claimButton:SetPos(370 * SCALE_FACTOR, 35 * SCALE_FACTOR)
- claimButton:SetSize(100 * SCALE_FACTOR, 30 * SCALE_FACTOR)
- claimButton:SetText("Claim Case")
- claimButton.DoClick = function()
- requestData.claimed = true
- requestData.claimedBy = LocalPlayer():SteamID64()
- claimButton:SetText("Claimed")
- claimButton:SetDisabled(true)
- createClaimedRequestUI(requestData)
- -- Remove the admin request menu
- if IsValid(mainPanel) then
- mainPanel:Remove()
- end
- net.Start("AdminRequestClaim")
- net.WriteTable(requestData)
- net.SendToServer()
- -- Remove the claimed request from the list and move the rest up
- for i, panel in ipairs(requestList:GetItems()) do
- if panel == requestPanel then
- requestList:RemoveItem(requestPanel)
- table.remove(requestList:GetItems(), i)
- break
- end
- end
- -- Remove the claimed request from the requests table
- for i, req in ipairs(requests) do
- if req == requestData then
- table.remove(requests, i)
- break
- end
- end
- end
- end
- end
- -- Update the list of admin requests with the unclaimed requests
- adminRequests = unclaimedRequests
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement