Advertisement
wifiboost

Untitled

Mar 27th, 2023
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.32 KB | None | 0 0
  1. local function createAdminRequestUI(requests)
  2. if not IsValid(mainPanel) then
  3. -- Create the main panel using Xenin F4 framework
  4. surface.CreateFont("CustomFont", {
  5. font = "Arial",
  6. size = 15,
  7. weight = 400,
  8. antialias = true,
  9. shadow = false,
  10. })
  11. mainPanel = vgui.Create("XeninUI.Frame")
  12. mainPanel:SetSize(500 * SCALE_FACTOR, 600 * SCALE_FACTOR)
  13. local screenWidth, screenHeight = ScrW(), ScrH()
  14. mainPanel:SetPos(0, (screenHeight - mainPanel:GetTall()) / 2)
  15. mainPanel:SetTitle("Admin Requests")
  16. mainPanel:MakePopup()
  17. end
  18. local requestList = vgui.Create("DScrollPanel", mainPanel) -- Change DPanelList to DScrollPanel
  19. requestList:SetPos(10 * SCALE_FACTOR, 50 * SCALE_FACTOR + 12)
  20. requestList:SetSize(480 * SCALE_FACTOR, 520 * SCALE_FACTOR)
  21.  
  22. -- Hide the scrollbar
  23. requestList.VBar.Paint = function() end
  24. requestList.VBar.btnUp.Paint = function() end
  25. requestList.VBar.btnDown.Paint = function() end
  26. requestList.VBar.btnGrip.Paint = function() end
  27.  
  28. local unclaimedRequests = {}
  29.  
  30. local function createOutlinedButton(parent, x, y, w, h, text, onClick)
  31. local button = vgui.Create("XeninUI.Button", parent)
  32. button:SetPos(x, y)
  33. button:SetSize(w, h)
  34. button:SetText(text)
  35. button:SetFont("CustomFont") -- Set custom font
  36. button:SetTextColor( Color(227, 227, 227))
  37. button.Paint = function(self, w, h)
  38. draw.RoundedBox(4, 0, 0, w, h, Color(29, 29, 29, 255))
  39. draw.RoundedBox(4, 1, 1, w - 2, h - 2, Color(54, 54, 54, 255))
  40. end
  41. button.DoClick = onClick
  42. return button
  43. end
  44.  
  45. local buttonWidth = 280 * SCALE_FACTOR
  46. local buttonHeight = 30 * SCALE_FACTOR
  47.  
  48. for i, requestData in ipairs(requests) do
  49. if not requestData.claimed then
  50. table.insert(unclaimedRequests, requestData)
  51.  
  52. local requestPanel = vgui.Create("DPanel", requestList)
  53. requestPanel:SetSize(480 * SCALE_FACTOR, 100 * SCALE_FACTOR)
  54. requestPanel.Paint = function(self, w, h)
  55. draw.RoundedBox(4, 0, 0, w, h, Color(29, 29, 29, 255))
  56. draw.RoundedBox(4, 1, 1, w - 2, h - 2, Color(54, 54, 54, 255))
  57. end
  58. requestList:AddItem(requestPanel)
  59.  
  60. -- Add user avatar
  61. local avatar = vgui.Create("AvatarImage", requestPanel)
  62. avatar:SetSize(64 * SCALE_FACTOR, 64 * SCALE_FACTOR)
  63. avatar:SetPos(10 * SCALE_FACTOR, 18 * SCALE_FACTOR)
  64. avatar:SetSteamID(requestData.steamID64, 64)
  65.  
  66. -- Add user name
  67. local nameLabel = vgui.Create("DLabel", requestPanel)
  68. nameLabel:SetFont("CustomFont") -- Set custom font
  69. nameLabel:SetTextColor( Color(227, 227, 227))
  70. nameLabel:SetText(requestData.name)
  71. nameLabel:SetPos(84 * SCALE_FACTOR, 18 * SCALE_FACTOR)
  72. nameLabel:SizeToContents()
  73.  
  74. -- Add request message
  75. local messageLabel = vgui.Create("DLabel", requestPanel)
  76. messageLabel:SetFont("CustomFont") -- Set custom font
  77. messageLabel:SetTextColor( Color(227, 227, 227))
  78. messageLabel:SetText(requestData.message)
  79. messageLabel:SetPos(84 * SCALE_FACTOR, 48 * SCALE_FACTOR)
  80. messageLabel:SizeToContents()
  81.  
  82. -- Claim case button for each request
  83. local claimButton = vgui.Create("XeninUI.Button", requestPanel)
  84. claimButton:SetFont("CustomFont") -- Set custom font
  85. claimButton:SetTextColor( Color(227, 227, 227))
  86. claimButton:SetPos(370 * SCALE_FACTOR, 35 * SCALE_FACTOR)
  87. claimButton:SetSize(100 * SCALE_FACTOR, 30 * SCALE_FACTOR)
  88. claimButton:SetText("Claim Case")
  89. claimButton.DoClick = function()
  90. requestData.claimed = true
  91. requestData.claimedBy = LocalPlayer():SteamID64()
  92. claimButton:SetText("Claimed")
  93. claimButton:SetDisabled(true)
  94. createClaimedRequestUI(requestData)
  95.  
  96. -- Remove the admin request menu
  97. if IsValid(mainPanel) then
  98. mainPanel:Remove()
  99. end
  100.  
  101. net.Start("AdminRequestClaim")
  102. net.WriteTable(requestData)
  103. net.SendToServer()
  104.  
  105. -- Remove the claimed request from the list and move the rest up
  106. for i, panel in ipairs(requestList:GetItems()) do
  107. if panel == requestPanel then
  108. requestList:RemoveItem(requestPanel)
  109. table.remove(requestList:GetItems(), i)
  110. break
  111. end
  112. end
  113. -- Remove the claimed request from the requests table
  114. for i, req in ipairs(requests) do
  115. if req == requestData then
  116. table.remove(requests, i)
  117. break
  118. end
  119. end
  120. end
  121. end
  122. end
  123.  
  124. -- Update the list of admin requests with the unclaimed requests
  125. adminRequests = unclaimedRequests
  126. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement