Guest User

cl_buttons.lua

a guest
Sep 5th, 2018
440
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 29.76 KB | None | 0 0
  1. /*----------------------------------------------------------------------
  2. Leak by Famouse
  3.  
  4. Play good games:↓
  5. http://store.steampowered.com/curator/32364216
  6.  
  7. Subscribe to the channel:↓
  8. www.youtube.com/c/Famouse
  9.  
  10. More leaks in the discord:↓
  11. https://discord.gg/rFdQwzm
  12. ------------------------------------------------------------------------*/
  13.  
  14. -- If you do not know Lua fairly well, I would suggest that you do not edit this file --
  15.  
  16.  
  17. -- [[ Sidebar Buttons ]] --
  18.  
  19. /*
  20. This is for editing the buttons that show up on the right side when selecting a user on the scoreboard
  21.  
  22. ------------------------
  23. Creating A Custom Button
  24. ------------------------
  25.  
  26.  
  27. To create a custom button, you must create a custom category to hold all of your custom buttons.
  28. Create a new anonymous table inside of the 'FancyScoreboard.Buttons' table. This table MUST contain these three variables:
  29. - Category (String) The text that shows on the label above your buttons
  30. - Enabled (Bool | Function) Either a bool or a function to determine whether to display it to the player or not
  31. - Buttons (Table) A table that contains all of the buttons that are part of this category
  32. (More info on these can be found in the 'Documentation' section below)
  33.  
  34. Then, to create buttons inside of your category, create a new anonymous table inside of the "Buttons" sub-table you created.
  35. This table also has three REQUIRED variables:
  36. - Name (String | Function) The text that is written on your button
  37. - Enabled (Bool | Function) Determines whether the user should be able to see your button
  38. - Action (Function) A function that's called when the user clicks the button
  39. (Again, more information on these can be found below)
  40.  
  41.  
  42. -------
  43. Example
  44. -------
  45.  
  46.  
  47. -- This table should be placed in "FancyScoreboard.Buttons"
  48. {
  49. Category = "Example Category", -- The text for the label above the buttons
  50. Enabled = true, -- Category will always show
  51. Buttons = {
  52. -- Basic button
  53. {
  54. Name = "Print Hi", -- Button text
  55. Enabled = true, -- Always enabled
  56. Action = function(selectedPly) -- Callback for button press
  57. chat.AddText(FancyScoreboard.Colors.Accent, "Currently selecting: ", FancyScoreboard.Colors.Text, selectedPly:Nick())
  58. end
  59. }, -- Don't forget this comma
  60.  
  61. -- Slightly more advanced button
  62. {
  63. Name = function(selectedPly)
  64. -- Button's text will be selected player's name
  65. return selectedPly:Nick()
  66. end,
  67. Enabled = function(selectedPly)
  68. -- Button only enabled if local player is admin
  69. return LocalPlayer():IsAdmin()
  70. end,
  71. Action = function(selectedPly)
  72. RunConsoleCommand("say", "Hello " .. selectedPly.Nick())
  73. end
  74. }, -- Don't forget this comma
  75. }
  76. }, -- Don't forget the ending comma
  77.  
  78.  
  79. --------------------
  80. Documentation Format
  81. --------------------
  82.  
  83.  
  84. // Variable Name //
  85. == Type Information
  86. -- Short Description
  87. [Ex.] Example
  88.  
  89.  
  90. -------------
  91. Documentation
  92. -------------
  93.  
  94. -- Main table, holds everything that is related to one specific "category" of buttons
  95. {
  96. // Category //
  97. == String
  98. -- This is the text that will show on the label above your buttons
  99. [Ex.] Category = "Your Category",
  100.  
  101.  
  102. // Enabled //
  103. == Boolean [OR] Function(selectedPly)
  104. == The function has 1 argument: The player that is currently selected on the scoreboard
  105. == The function must return a boolean value
  106. -- If your category of buttons should show up for the user
  107. [Ex.] Enabled = true, -- Category and buttons will always show
  108. [Ex.] Enabled = false, -- Will never show
  109. [Ex.] Enabled = function(selectedPly)
  110. -- Button will only show if the local player is admin
  111. return LocalPlayer():IsAdmin()
  112. end,
  113.  
  114.  
  115. -- Table that contains all of the buttons for this category
  116. Buttons = {
  117. {
  118. // Name //
  119. == String OR Function(selectedPly)
  120. == The function has 1 argument: The currently selected player
  121. == The function must return a string
  122. -- The text that shows on the button
  123. [Ex.] Name = "Your button",
  124. [Ex.] Name = function(selectedPlayer)
  125. return selectedPlayer:Nick()
  126. end
  127.  
  128.  
  129. // Enabled //
  130. == Boolean OR Function(selectedPly)
  131. == The function has 1 argument: The currently selected player
  132. == The function has 1 argument: The currently selected player
  133. == The function must return a boolean value
  134. -- Whether your buttons will show up for the user.
  135. [Ex.] Enabled = true, -- Button will always show
  136.  
  137. [Ex.] Enabled = function(selectedPly)
  138. -- Button will only show if the local player is admin
  139. return LocalPlayer():IsAdmin()
  140. end,
  141.  
  142.  
  143. // Action //
  144. == Function(selectedPly)
  145. == The argument, "selectedPly", is the player currently selected on the scoreboard
  146. -- The callback function that's called when the user presses the button
  147. [Ex.] Action = function(selectedPly)
  148. -- Prints out the name of the selected player using the "Accent" color from the current theme
  149. chat.AddText(FancyScoreboard.Colors.Accent, "You have selected ", selectedPly:Nick())
  150. end
  151. },
  152. },
  153. },
  154.  
  155. !! Make sure not to forget the ending commas after the closing brackets for the tables !!
  156. */
  157.  
  158. FancyScoreboard.Buttons = {
  159. -- Basic Actions
  160. {
  161. Category = FancyScoreboard.GetPhrase("BasicActions"),
  162. Enabled = FancyScoreboard.Modules.Basic_Actions,
  163. Buttons = {
  164. {
  165. Name = FancyScoreboard.GetPhrase("CopySteamID"),
  166. Enabled = true,
  167. Action = function(selectedPly)
  168. SetClipboardText(selectedPly:SteamID())
  169. chat.AddText(FancyScoreboard.Colors.Accent, FancyScoreboard.GetPhrase("CopiedID"))
  170. end
  171. },
  172. {
  173. Name = FancyScoreboard.GetPhrase("OpenProfile"),
  174. Enabled = true,
  175. Action = function(selectedPly)
  176. if selectedPly:SteamID() ~= "NULL" then
  177. gui.OpenURL("http://www.steamcommunity.com/profiles/" .. tostring(selectedPly:SteamID64()) .. "/")
  178. else
  179. chat.AddText(FancyScoreboard.Colors.Accent, FancyScoreboard.GetPhrase("ProfileBot"))
  180. end
  181. end
  182. },
  183. }
  184. },
  185.  
  186. -- DarkRP Actions
  187. {
  188. Category = FancyScoreboard.GetPhrase("DarkRPActions"),
  189. Enabled = function(selectedPly)
  190. return DarkRP ~= nil and LocalPlayer():IsAdmin() and FancyScoreboard.Modules.DarkRP_Actions
  191. end,
  192. Buttons = {
  193. {
  194. Name = FancyScoreboard.GetPhrase("SetMoney"),
  195. Enabled = true,
  196. Action = function(selectedPly)
  197. FancyScoreboard.OpenDialogue({
  198. Title = FancyScoreboard.GetPhrase("SetMoneyTitle", {"%player%", selectedPly:Nick()}),
  199. Type = "Confirm",
  200. Width = 450,
  201. Build = function(menu)
  202. local settings = {
  203. Amount = 0
  204. }
  205.  
  206. local amountLabel = vgui.Create("DLabel", menu)
  207. amountLabel:SetText(FancyScoreboard.GetPhrase("Amount") .. ":")
  208. amountLabel:SetFont("FancyScoreboard.Normal")
  209. amountLabel:SizeToContents()
  210. amountLabel:SetPos(0, 0)
  211.  
  212. local amountBox = vgui.Create("DTextEntry", menu)
  213. amountBox:SetText("")
  214. amountBox:SetPos(0, amountLabel:GetTall() + 5)
  215. print("amountBox: " .. amountLabel:GetTall() + 5)
  216. amountBox:SetSize(menu:GetWide(), 26)
  217. amountBox:SetFont("FancyScoreboard.Normal")
  218. amountBox:SetNumeric(true)
  219.  
  220. function amountBox:OnChange()
  221. settings.Amount = tonumber(self:GetText())
  222. end
  223.  
  224. return settings
  225. end,
  226. OnAccept = function(settings)
  227. RunConsoleCommand("darkrp", "setmoney", selectedPly:Nick(), tostring(settings.Amount))
  228. end
  229. })
  230. end
  231. },
  232. {
  233. Name = FancyScoreboard.GetPhrase("JobBan"),
  234. Enabled = function(selectedPly)
  235. return DarkRP ~= nil and LocalPlayer():IsAdmin() and FancyScoreboard.Modules.DarkRP_Actions
  236. end,
  237. Action = function(selectedPly)
  238. FancyScoreboard.OpenDialogue({
  239. Title = FancyScoreboard.GetPhrase("JobBanTitle", {"%player%", selectedPly:Nick()}),
  240. Type = "Confirm",
  241. Width = 450,
  242. Build = function(menu)
  243. local settings = {
  244. Job = 1,
  245. Time = 0
  246. }
  247.  
  248. local timeChoices = {
  249. [FancyScoreboard.GetPhrase("Forever")] = 0,
  250. [FancyScoreboard.GetPhrase("Second")] = 1,
  251. [FancyScoreboard.GetPhrase("Minute")] = 60,
  252. [FancyScoreboard.GetPhrase("Hour")] = 3600,
  253. [FancyScoreboard.GetPhrase("Day")] = 86400,
  254. [FancyScoreboard.GetPhrase("Week")] = 604800
  255. }
  256.  
  257. local yPos = 0
  258. local timeMult = timeChoices["Hours"]
  259.  
  260. local jobLabel = vgui.Create("DLabel", menu)
  261. jobLabel:SetText(FancyScoreboard.GetPhrase("Job") .. ":")
  262. jobLabel:SetFont("FancyScoreboard.Normal")
  263. jobLabel:SizeToContents()
  264. jobLabel:SetPos(0, yPos)
  265.  
  266. yPos = yPos + jobLabel:GetTall() + 5
  267.  
  268. local jobBox = vgui.Create("DComboBox", menu)
  269. jobBox:SetFont("FancyScoreboard.Normal")
  270. jobBox:SetSize(menu:GetWide(), 26)
  271. jobBox:SetPos(0, yPos)
  272.  
  273. for k, v in pairs(FancyScoreboard.GetDarkRPJobs()) do
  274. jobBox:AddChoice(v.name, v.team)
  275. end
  276.  
  277. jobBox:ChooseOption(team.GetName(selectedPly:Team()))
  278.  
  279. function jobBox:OnSelect(index, value, boxData)
  280. settings.Job = boxData
  281. end
  282.  
  283. yPos = yPos + jobBox:GetTall() + 25
  284.  
  285. local timeLabel = vgui.Create("DLabel", menu)
  286. timeLabel:SetText(FancyScoreboard.GetPhrase("Time") .. ":")
  287. timeLabel:SetFont("FancyScoreboard.Normal")
  288. timeLabel:SizeToContents()
  289. timeLabel:SetPos(0, yPos)
  290.  
  291. yPos = yPos + timeLabel:GetTall() + 5
  292.  
  293. local timeField = vgui.Create("DNumberWang", menu)
  294. timeField:SetPos(0, yPos)
  295. timeField:SetDecimals(0)
  296. timeField:SetMinMax(0, 10000)
  297. timeField:SetValue(1)
  298.  
  299. function timeField:OnValueChanged(val)
  300. settings.Time = val * timeMult
  301. end
  302.  
  303. yPos = yPos + timeField:GetTall() + 5
  304.  
  305. local timeBox = vgui.Create("DComboBox", menu)
  306. timeBox:SetFont("FancyScoreboard.Normal")
  307. timeBox:SetSize(menu:GetWide(), 26)
  308. timeBox:SetPos(0, yPos)
  309.  
  310. for k, v in SortedPairsByValue(timeChoices) do
  311. timeBox:AddChoice(k, v)
  312. end
  313.  
  314. timeBox:ChooseOption(FancyScoreboard.GetPhrase("Forever"))
  315.  
  316. function timeBox:OnSelect(index, value, boxData)
  317. timeMult = boxData
  318. settings.Time = settings.Time * timeMult
  319. end
  320.  
  321. return settings
  322. end,
  323. OnAccept = function(settings)
  324. RunConsoleCommand("darkrp", "teamban", tostring(selectedPly:Nick()), tostring(settings.Job), tostring(settings.Time))
  325. end,
  326. })
  327. end,
  328. },
  329. {
  330. Name = FancyScoreboard.GetPhrase("JobUnban"),
  331. Enabled = function(selectedPly)
  332. return DarkRP ~= nil and LocalPlayer():IsAdmin() and FancyScoreboard.Modules.DarkRP_Actions
  333. end,
  334. Action = function(selectedPly)
  335. FancyScoreboard.OpenDialogue({
  336. Title = FancyScoreboard.GetPhrase("JobUnbanTitle", {"%player%", selectedPly:Nick()}),
  337. Type = "Confirm",
  338. Width = 450,
  339. Build = function(menu)
  340. local settings = {
  341. Job = 1
  342. }
  343.  
  344. local yPos = 0
  345.  
  346. local jobLabel = vgui.Create("DLabel", menu)
  347. jobLabel:SetText(FancyScoreboard.GetPhrase("Job") .. ":")
  348. jobLabel:SetFont("FancyScoreboard.Normal")
  349. jobLabel:SizeToContents()
  350. jobLabel:SetPos(0, yPos)
  351.  
  352. yPos = yPos + jobLabel:GetTall() + 5
  353.  
  354. local jobBox = vgui.Create("DComboBox", menu)
  355. jobBox:SetFont("FancyScoreboard.Normal")
  356. jobBox:SetSize(menu:GetWide(), 26)
  357. jobBox:SetPos(0, yPos)
  358.  
  359. for k, v in pairs(FancyScoreboard.GetDarkRPJobs()) do
  360. jobBox:AddChoice(v.name, v.team)
  361. end
  362.  
  363. jobBox:ChooseOption(team.GetName(selectedPly:Team()))
  364.  
  365. function jobBox:OnSelect(index, value, boxData)
  366. settings.Job = boxData
  367. end
  368.  
  369. return settings
  370. end,
  371. OnAccept = function(settings)
  372. RunConsoleCommand("darkrp", "teamunban", tostring(selectedPly:Nick()), tostring(settings.Job))
  373. end,
  374. })
  375. end,
  376. }
  377. }
  378. },
  379.  
  380. -- ULX Actions
  381. {
  382. Category = FancyScoreboard.GetPhrase("ULXActions"),
  383. Enabled = function(selectedPly)
  384. return ulx ~= nil and FancyScoreboard.Modules.ULX_Actions == true
  385. end,
  386. Buttons = {
  387. {
  388. Name = FancyScoreboard.GetPhrase("Goto"),
  389. Enabled = function(selectedPly) return LocalPlayer():query("ulx goto") end,
  390. Action = function(selectedPly)
  391. RunConsoleCommand("ulx", "goto", selectedPly:Nick())
  392. end
  393. },
  394. {
  395. Name = FancyScoreboard.GetPhrase("Bring"),
  396. Enabled = function(selectedPly) return LocalPlayer():query("ulx bring") end,
  397. Action = function(selectedPly)
  398. RunConsoleCommand("ulx", "bring", selectedPly:Nick())
  399. end
  400. },
  401. {
  402. Name = FancyScoreboard.GetPhrase("Slay"),
  403. Enabled = function(selectedPly) return LocalPlayer():query("ulx slay") end,
  404. Action = function(selectedPly)
  405. RunConsoleCommand("ulx", "slay", selectedPly:Nick())
  406. end
  407. },
  408. {
  409. Name = FancyScoreboard.GetPhrase("Freeze"),
  410. Enabled = function(selectedPly) return LocalPlayer():query("ulx freeze") end,
  411. Action = function(selectedPly)
  412. RunConsoleCommand("ulx", "freeze", selectedPly:Nick())
  413. end
  414. },
  415. {
  416. Name = FancyScoreboard.GetPhrase("Unfreeze"),
  417. Enabled = function(selectedPly) return LocalPlayer():query("ulx unfreeze") end,
  418. Action = function(selectedPly)
  419. RunConsoleCommand("ulx", "unfreeze", selectedPly:Nick())
  420. end
  421. },
  422. {
  423. Name = FancyScoreboard.GetPhrase("Spectate"),
  424. Enabled = function(selectedPly) return LocalPlayer():query("ulx spectate") end,
  425. Action = function(selectedPly)
  426. RunConsoleCommand("ulx", "spectate", selectedPly:Nick())
  427. end
  428. },
  429. {
  430. Name = FancyScoreboard.GetPhrase("Kick"),
  431. Enabled = function(selectedPly) return LocalPlayer():query("ulx kick") end,
  432. Action = function(selectedPly)
  433. FancyScoreboard.OpenDialogue({
  434. Title = FancyScoreboard.GetPhrase("KickTitle", {"%player%", selectedPly:Nick()}),
  435. Type = "Confirm",
  436. Width = 450,
  437. Build = function(menu)
  438. local settings = {
  439. Reason = FancyScoreboard.Config.DefaultKickReason,
  440. }
  441.  
  442. local reasonLabel = vgui.Create("DLabel", menu)
  443. reasonLabel:SetText(FancyScoreboard.GetPhrase("Reason") .. ":")
  444. reasonLabel:SetFont("FancyScoreboard.Normal")
  445. reasonLabel:SizeToContents()
  446. reasonLabel:SetPos(0, 0)
  447.  
  448. local reasonBox = vgui.Create("DTextEntry", menu)
  449. reasonBox:SetText("")
  450. reasonBox:SetPos(0, reasonLabel:GetTall() + 5)
  451. reasonBox:SetSize(menu:GetWide(), 26)
  452. reasonBox:SetFont("FancyScoreboard.Normal")
  453.  
  454. function reasonBox:OnChange()
  455. settings.Reason = self:GetText()
  456. end
  457.  
  458. return settings
  459. end,
  460. OnAccept = function(settings)
  461. if settings.Reason then
  462. RunConsoleCommand("ulx", "kick", selectedPly:Nick(), tostring(settings.Reason))
  463. else
  464. RunConsoleCommand("ulx", "kick", selectedPly:Nick())
  465. end
  466. end
  467. })
  468. end
  469. },
  470. {
  471. Name = "Ban",
  472. Enabled = function(selectedPly) return LocalPlayer():query("ulx ban") end,
  473. Action = function(selectedPly)
  474. FancyScoreboard.OpenDialogue({
  475. Title = FancyScoreboard.GetPhrase("BanTitle", {"%player%", selectedPly:Nick()}),
  476. Type = "Confirm",
  477. Width = 450,
  478. Build = function(menu)
  479. local settings = {
  480. Reason = FancyScoreboard.Config.DefaultBanReason,
  481. Length = 0
  482. }
  483.  
  484. local banLengths = {
  485. [FancyScoreboard.GetPhrase("Forever")] = 0,
  486. ["1 " .. FancyScoreboard.GetPhrase("Hour")] = 60,
  487. ["1 " .. FancyScoreboard.GetPhrase("Day")] = 1440,
  488. ["1 " .. FancyScoreboard.GetPhrase("Week")] = 10080,
  489. ["1 " .. FancyScoreboard.GetPhrase("Month")] = 43800,
  490. ["1 " .. FancyScoreboard.GetPhrase("Year")] = 525600
  491. }
  492.  
  493. local reasonLabel = vgui.Create("DLabel", menu)
  494. reasonLabel:SetText(FancyScoreboard.GetPhrase("Reason") .. ":")
  495. reasonLabel:SetFont("FancyScoreboard.Normal")
  496. reasonLabel:SizeToContents()
  497. reasonLabel:SetPos(0, 0)
  498.  
  499. local reasonBox = vgui.Create("DTextEntry", menu)
  500. reasonBox:SetText("")
  501. reasonBox:SetPos(0, reasonLabel:GetTall() + 5)
  502. reasonBox:SetSize(menu:GetWide(), 26)
  503. reasonBox:SetFont("FancyScoreboard.Normal")
  504.  
  505. function reasonBox:OnChange()
  506. settings.Reason = self:GetText()
  507. end
  508.  
  509. local lengthLabel = vgui.Create("DLabel", menu)
  510. lengthLabel:SetText(FancyScoreboard.GetPhrase("Time") .. ":")
  511. lengthLabel:SetFont("FancyScoreboard.Normal")
  512. lengthLabel:SizeToContents()
  513. lengthLabel:SetPos(0, reasonLabel:GetTall() + reasonBox:GetTall() + 10)
  514.  
  515. local lengthBox = vgui.Create("DComboBox", menu)
  516. lengthBox:SetFont("FancyScoreboard.Normal")
  517. lengthBox:SetSize(menu:GetWide(), 26)
  518. lengthBox:SetPos(0, reasonLabel:GetTall() + reasonBox:GetTall() + lengthLabel:GetTall() + 15)
  519.  
  520. for k, v in SortedPairsByValue(banLengths) do
  521. lengthBox:AddChoice(k, v)
  522. end
  523.  
  524. lengthBox:ChooseOption(FancyScoreboard.GetPhrase("Forever"))
  525.  
  526. function lengthBox:OnSelect(index, value, boxData)
  527. settings.Length = boxData
  528. end
  529.  
  530. return settings
  531. end,
  532. OnAccept = function(settings)
  533. if settings.Reason then
  534. RunConsoleCommand("ulx", "ban", selectedPly:Nick(), tostring(settings.Length), tostring(settings.Reason))
  535. else
  536. RunConsoleCommand("ulx", "ban", selectedPly:Nick(), tostring(settings.Length))
  537. end
  538. end
  539. })
  540. end
  541. }
  542. }
  543. },
  544.  
  545. -- Serverguard actions
  546. {
  547. Category = FancyScoreboard.GetPhrase("ServerguardActions"),
  548. Enabled = function(selectedPly)
  549. return serverguard ~= nil and FancyScoreboard.Modules.Serverguard_Actions
  550. end,
  551. Buttons = {
  552. {
  553. Name = FancyScoreboard.GetPhrase("Bring"),
  554. Enabled = function(selectedPly)
  555. return serverguard.player:HasPermission(LocalPlayer(), "Bring")
  556. end,
  557. Action = function(selectedPly)
  558. RunConsoleCommand("sg", "bring", selectedPly:Nick())
  559. end
  560. },
  561. {
  562. Name = FancyScoreboard.GetPhrase("Goto"),
  563. Enabled = function(selectedPly)
  564. return serverguard.player:HasPermission(LocalPlayer(), "Goto")
  565. end,
  566. Action = function(selectedPly)
  567. RunConsoleCommand("sg", "goto", selectedPly:Nick())
  568. end
  569. },
  570. {
  571. Name = FancyScoreboard.GetPhrase("Slay"),
  572. Enabled = function(selectedPly)
  573. return serverguard.player:HasPermission(LocalPlayer(), "Slay")
  574. end,
  575. Action = function(selectedPly)
  576. RunConsoleCommand("sg", "slay", selectedPly:Nick())
  577. end
  578. },
  579. {
  580. Name = FancyScoreboard.GetPhrase("ToggleFreeze"),
  581. Enabled = function(selectedPly)
  582. return serverguard.player:HasPermission(LocalPlayer(), "Freeze")
  583. end,
  584. Action = function(selectedPly)
  585. RunConsoleCommand("sg", "freeze", selectedPly:Nick())
  586. end
  587. },
  588. {
  589. Name = FancyScoreboard.GetPhrase("Spectate"),
  590. Enabled = function(selectedPly)
  591. return serverguard.player:HasPermission(LocalPlayer(), "Spectate")
  592. end,
  593. Action = function(selectedPly)
  594. RunConsoleCommand("sg", "spectate", selectedPly:Nick())
  595. end
  596. },
  597. {
  598. Name = FancyScoreboard.GetPhrase("Kick"),
  599. Enabled = function(selectedPly)
  600. return serverguard.player:HasPermission(LocalPlayer(), "Kick")
  601. end,
  602. Action = function(selectedPly)
  603. FancyScoreboard.OpenDialogue({
  604. Title = FancyScoreboard.GetPhrase("KickTitle", {"%player%", selectedPly:Nick()}),
  605. Type = "Confirm",
  606. Width = 450,
  607. Build = function(menu)
  608. local settings = {
  609. Reason = FancyScoreboard.Config.DefaultKickReason,
  610. }
  611.  
  612. local reasonLabel = vgui.Create("DLabel", menu)
  613. reasonLabel:SetText(FancyScoreboard.GetPhrase("Reason") .. ":")
  614. reasonLabel:SetFont("FancyScoreboard.Normal")
  615. reasonLabel:SizeToContents()
  616. reasonLabel:SetPos(0, 0)
  617.  
  618. local reasonBox = vgui.Create("DTextEntry", menu)
  619. reasonBox:SetText("")
  620. reasonBox:SetPos(0, reasonLabel:GetTall() + 5)
  621. reasonBox:SetSize(menu:GetWide(), 26)
  622. reasonBox:SetFont("FancyScoreboard.Normal")
  623.  
  624. function reasonBox:OnChange()
  625. settings.Reason = self:GetText()
  626. end
  627.  
  628. return settings
  629. end,
  630. OnAccept = function(settings)
  631. if settings.Reason then
  632. RunConsoleCommand("sg", "kick", selectedPly:Nick(), tostring(settings.Reason))
  633. else
  634. RunConsoleCommand("sg", "kick", selectedPly:Nick())
  635. end
  636. end
  637. })
  638. end
  639. },
  640. {
  641. Name = "Ban",
  642. Enabled = function(selectedPly)
  643. return serverguard.player:HasPermission(LocalPlayer(), "Ban")
  644. end,
  645. Action = function(selectedPly)
  646. FancyScoreboard.OpenDialogue({
  647. Title = FancyScoreboard.GetPhrase("BanTitle", {"%player%", selectedPly:Nick()}),
  648. Type = "Confirm",
  649. Width = 450,
  650. Build = function(menu)
  651. local settings = {
  652. Reason = FancyScoreboard.Config.DefaultBanReason,
  653. Length = 0
  654. }
  655.  
  656. local banLengths = {
  657. [FancyScoreboard.GetPhrase("Forever")] = 0,
  658. ["1 " .. FancyScoreboard.GetPhrase("Hour")] = 60,
  659. ["1 " .. FancyScoreboard.GetPhrase("Day")] = 1440,
  660. ["1 " .. FancyScoreboard.GetPhrase("Week")] = 10080,
  661. ["1 " .. FancyScoreboard.GetPhrase("Month")] = 43800,
  662. ["1 " .. FancyScoreboard.GetPhrase("Year")] = 525600
  663. }
  664.  
  665. local reasonLabel = vgui.Create("DLabel", menu)
  666. reasonLabel:SetText(FancyScoreboard.GetPhrase("Reason") .. ":")
  667. reasonLabel:SetFont("FancyScoreboard.Normal")
  668. reasonLabel:SizeToContents()
  669. reasonLabel:SetPos(0, 0)
  670.  
  671. local reasonBox = vgui.Create("DTextEntry", menu)
  672. reasonBox:SetText("")
  673. reasonBox:SetPos(0, reasonLabel:GetTall() + 5)
  674. reasonBox:SetSize(menu:GetWide(), 26)
  675. reasonBox:SetFont("FancyScoreboard.Normal")
  676.  
  677. function reasonBox:OnChange()
  678. settings.Reason = self:GetText()
  679. end
  680.  
  681. local lengthLabel = vgui.Create("DLabel", menu)
  682. lengthLabel:SetText(FancyScoreboard.GetPhrase("Time") .. ":")
  683. lengthLabel:SetFont("FancyScoreboard.Normal")
  684. lengthLabel:SizeToContents()
  685. lengthLabel:SetPos(0, reasonLabel:GetTall() + reasonBox:GetTall() + 10)
  686.  
  687. local lengthBox = vgui.Create("DComboBox", menu)
  688. lengthBox:SetFont("FancyScoreboard.Normal")
  689. lengthBox:SetSize(menu:GetWide(), 26)
  690. lengthBox:SetPos(0, reasonLabel:GetTall() + reasonBox:GetTall() + lengthLabel:GetTall() + 15)
  691.  
  692. for k, v in SortedPairsByValue(banLengths) do
  693. lengthBox:AddChoice(k, v)
  694. end
  695.  
  696. lengthBox:ChooseOption(FancyScoreboard.GetPhrase("Forever"))
  697.  
  698. function lengthBox:OnSelect(index, value, boxData)
  699. settings.Length = boxData
  700. end
  701.  
  702. return settings
  703. end,
  704. OnAccept = function(settings)
  705. if settings.Reason then
  706. RunConsoleCommand("sg", "ban", selectedPly:Nick(), tostring(settings.Length), tostring(settings.Reason))
  707. else
  708. RunConsoleCommand("sg", "ban", selectedPly:Nick(), tostring(settings.Length))
  709. end
  710. end
  711. })
  712. end
  713. }
  714. }
  715. },
  716.  
  717. -- FAdmin Actions
  718. {
  719. Category = FancyScoreboard.GetPhrase("FAdminActions"),
  720. Enabled = function(selectedPly)
  721. return FAdmin ~= nil and FancyScoreboard.Modules.FAdmin_Actions
  722. end,
  723. Buttons = {
  724. {
  725. Name = FancyScoreboard.GetPhrase("Bring"),
  726. Enabled = function(selectedPly)
  727. return FAdmin.Access.PlayerHasPrivilege(LocalPlayer(), "bring")
  728. end,
  729. Action = function(selectedPly)
  730. RunConsoleCommand("FAdmin", "bring", selectedPly:Nick())
  731. end
  732. },
  733. {
  734. Name = FancyScoreboard.GetPhrase("Goto"),
  735. Enabled = function(selectedPly)
  736. return FAdmin.Access.PlayerHasPrivilege(LocalPlayer(), "goto")
  737. end,
  738. Action = function(selectedPly)
  739. RunConsoleCommand("FAdmin", "goto", selectedPly:Nick())
  740. end
  741. },
  742. {
  743. Name = FancyScoreboard.GetPhrase("Slay"),
  744. Enabled = function(selectedPly)
  745. return FAdmin.Access.PlayerHasPrivilege(LocalPlayer(), "slay")
  746. end,
  747. Action = function(selectedPly)
  748. RunConsoleCommand("FAdmin", "slay", selectedPly:Nick())
  749. end
  750. },
  751. {
  752. Name = FancyScoreboard.GetPhrase("Freeze"),
  753. Enabled = function(selectedPly)
  754. return FAdmin.Access.PlayerHasPrivilege(LocalPlayer(), "freeze")
  755. end,
  756. Action = function(selectedPly)
  757. RunConsoleCommand("FAdmin", "freeze", selectedPly:Nick())
  758. end
  759. },
  760. {
  761. Name = FancyScoreboard.GetPhrase("Unfreeze"),
  762. Enabled = function(selectedPly)
  763. return FAdmin.Access.PlayerHasPrivilege(LocalPlayer(), "unfreeze")
  764. end,
  765. Action = function(selectedPly)
  766. RunConsoleCommand("FAdmin", "unfreeze", selectedPly:Nick())
  767. end
  768. },
  769. {
  770. Name = FancyScoreboard.GetPhrase("Kick"),
  771. Enabled = function(selectedPly)
  772. return FAdmin.Access.PlayerHasPrivilege(LocalPlayer(), "kick")
  773. end,
  774. Action = function(selectedPly)
  775. FancyScoreboard.OpenDialogue({
  776. Title = FancyScoreboard.GetPhrase("KickTitle", {"%player%", selectedPly:Nick()}),
  777. Type = "Confirm",
  778. Width = 450,
  779. Build = function(menu)
  780. local settings = {
  781. Reason = FancyScoreboard.Config.DefaultKickReason,
  782. }
  783.  
  784. local reasonLabel = vgui.Create("DLabel", menu)
  785. reasonLabel:SetText(FancyScoreboard.GetPhrase("Reason") .. ":")
  786. reasonLabel:SetFont("FancyScoreboard.Normal")
  787. reasonLabel:SizeToContents()
  788. reasonLabel:SetPos(0, 0)
  789.  
  790. local reasonBox = vgui.Create("DTextEntry", menu)
  791. reasonBox:SetText("")
  792. reasonBox:SetPos(0, reasonLabel:GetTall() + 5)
  793. reasonBox:SetSize(menu:GetWide(), 26)
  794. reasonBox:SetFont("FancyScoreboard.Normal")
  795.  
  796. function reasonBox:OnChange()
  797. settings.Reason = self:GetText()
  798. end
  799.  
  800. return settings
  801. end,
  802. OnAccept = function(settings)
  803. if settings.Reason then
  804. RunConsoleCommand("FAdmin", "kick", selectedPly:Nick(), tostring(settings.Reason))
  805. else
  806. RunConsoleCommand("FAdmin", "kick", selectedPly:Nick())
  807. end
  808. end
  809. })
  810. end
  811. },
  812. {
  813. Name = "Ban",
  814. Enabled = function(selectedPly)
  815. return FAdmin.Access.PlayerHasPrivilege(LocalPlayer(), "ban")
  816. end,
  817. Action = function(selectedPly)
  818. FancyScoreboard.OpenDialogue({
  819. Title = FancyScoreboard.GetPhrase("BanTitle", {"%player%", selectedPly:Nick()}),
  820. Type = "Confirm",
  821. Width = 450,
  822. Build = function(menu)
  823. local settings = {
  824. Reason = FancyScoreboard.Config.DefaultBanReason,
  825. Length = 0
  826. }
  827.  
  828. local banLengths = {
  829. [FancyScoreboard.GetPhrase("Forever")] = 0,
  830. ["1 " .. FancyScoreboard.GetPhrase("Hour")] = 60,
  831. ["1 " .. FancyScoreboard.GetPhrase("Day")] = 1440,
  832. ["1 " .. FancyScoreboard.GetPhrase("Week")] = 10080,
  833. ["1 " .. FancyScoreboard.GetPhrase("Month")] = 43800,
  834. ["1 " .. FancyScoreboard.GetPhrase("Year")] = 525600
  835. }
  836.  
  837. local reasonLabel = vgui.Create("DLabel", menu)
  838. reasonLabel:SetText(FancyScoreboard.GetPhrase("Reason") .. ":")
  839. reasonLabel:SetFont("FancyScoreboard.Normal")
  840. reasonLabel:SizeToContents()
  841. reasonLabel:SetPos(0, 0)
  842.  
  843. local reasonBox = vgui.Create("DTextEntry", menu)
  844. reasonBox:SetText("")
  845. reasonBox:SetPos(0, reasonLabel:GetTall() + 5)
  846. reasonBox:SetSize(menu:GetWide(), 26)
  847. reasonBox:SetFont("FancyScoreboard.Normal")
  848.  
  849. function reasonBox:OnChange()
  850. settings.Reason = self:GetText()
  851. end
  852.  
  853. local lengthLabel = vgui.Create("DLabel", menu)
  854. lengthLabel:SetText(FancyScoreboard.GetPhrase("Time") .. ":")
  855. lengthLabel:SetFont("FancyScoreboard.Normal")
  856. lengthLabel:SizeToContents()
  857. lengthLabel:SetPos(0, reasonLabel:GetTall() + reasonBox:GetTall() + 10)
  858.  
  859. local lengthBox = vgui.Create("DComboBox", menu)
  860. lengthBox:SetFont("FancyScoreboard.Normal")
  861. lengthBox:SetSize(menu:GetWide(), 26)
  862. lengthBox:SetPos(0, reasonLabel:GetTall() + reasonBox:GetTall() + lengthLabel:GetTall() + 15)
  863.  
  864. for k, v in SortedPairsByValue(banLengths) do
  865. lengthBox:AddChoice(k, v)
  866. end
  867.  
  868. lengthBox:ChooseOption(FancyScoreboard.GetPhrase("Forever"))
  869.  
  870. function lengthBox:OnSelect(index, value, boxData)
  871. settings.Length = boxData
  872. end
  873.  
  874. return settings
  875. end,
  876. OnAccept = function(settings)
  877. if settings.Reason then
  878. RunConsoleCommand("FAdmin", "ban", selectedPly:Nick(), tostring(settings.Length), tostring(settings.Reason))
  879. else
  880. RunConsoleCommand("FAdmin", "ban", selectedPly:Nick(), tostring(settings.Length))
  881. end
  882. end
  883. })
  884. end
  885. }
  886. }
  887. },
  888. }
  889.  
  890. /*------------------------------------------------------------------------
  891. Donation for leaks
  892.  
  893. Qiwi Wallet 4890494419811120
  894. YandexMoney 410013095053302
  895. WebMoney(WMR) R235985364414
  896. WebMoney(WMZ) Z309855690994
  897. ------------------------------------------------------------------------*/
Advertisement
Add Comment
Please, Sign In to add comment