Advertisement
Guest User

Untitled

a guest
Jun 27th, 2013
7,933
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 68.88 KB | None | 0 0
  1. local VoteVGUI = {}
  2. local QuestionVGUI = {}
  3. local PanelNum = 0
  4. local LetterWritePanel
  5. VoteQueues = VoteQueues or {}
  6.  
  7. function MsgDoVote(msg)
  8. local _, chatY = chat.GetChatBoxPos()
  9.  
  10. local question = msg:ReadString()
  11. local voteid = msg:ReadString()
  12. local timeleft = msg:ReadFloat()
  13. if timeleft == 0 then
  14. timeleft = 100
  15. end
  16. local OldTime = CurTime()
  17. if string.find(voteid, LocalPlayer():EntIndex()) then return end --If it's about you then go away
  18. if not IsValid(LocalPlayer()) then return end -- Sent right before player initialisation
  19.  
  20. VoteQueues[voteid] = table.Count(VoteQueues) + 1
  21.  
  22. LocalPlayer():EmitSound("Town.d1_town_02_elevbell1", 100, 100)
  23. local panel = vgui.Create("DFrame")
  24. panel:SetPos(3, -50)
  25. panel:SetTitle("")
  26. panel:SetSize(220, 70)
  27. panel:SetSizable(false)
  28. panel.btnClose:SetVisible(false)
  29. panel.btnMaxim:SetVisible(false)
  30. panel.btnMinim:SetVisible(false)
  31. panel:SetDraggable(false)
  32. function panel:Close()
  33. VoteQueues[voteid] = nil
  34. for _, v in pairs (VoteQueues) do
  35. VoteQueues[_] = math.max(v - 1, 1)
  36. end
  37.  
  38. PanelNum = PanelNum - 70
  39. VoteVGUI[voteid .. "vote"] = nil
  40.  
  41. local num = 0
  42. for k,v in SortedPairs(VoteVGUI) do
  43. v:SetPos(3, chatY - 145 - num)
  44. num = num + 70
  45. end
  46.  
  47. for k,v in SortedPairs(QuestionVGUI) do
  48. v:SetPos(3, chatY - 145 - num)
  49. num = num + 300
  50. end
  51. self:Remove()
  52. end
  53. panel.Paint = function(me)
  54. local w, h = me:GetSize()
  55. draw.RoundedBox(4, 0, 0, w, h, Color(0, 0, 0, 255))
  56. draw.RoundedBox(4, 1, 1, w - 2, h - 2, Color(60, 60, 60, 255))
  57.  
  58. draw.RoundedBox(0, w - 12, 4, 8, h - 8, color_black)
  59. draw.RoundedBox(0, w - 11, 5, 6, h - 11, Color(25, 25, 25, 255))
  60.  
  61. local frac = (CurTime() - OldTime) / timeleft
  62. draw.RoundedBox(0, w - 11, 5 + h * frac, 6, h - h * frac - 10, Color(100, 100, 100, 255))
  63. end
  64.  
  65. function panel:Think()
  66. if timeleft - (CurTime() - OldTime) <= 0 then
  67. return
  68. panel:Close()
  69. end
  70.  
  71. panel.Pos = panel.Pos or -70
  72. panel.Pos = Lerp(5 * FrameTime(), panel.Pos, 3 + (VoteQueues[voteid] - 1) * 73)
  73.  
  74. panel:SetPos(3, panel.Pos)
  75. end
  76.  
  77. panel:SetKeyboardInputEnabled(false)
  78. panel:SetMouseInputEnabled(true)
  79. panel:SetVisible(true)
  80.  
  81. local expl = string.Explode("\n", question)
  82. local name = expl[1]
  83.  
  84. local line2 = ""
  85. for i = 2, #expl do
  86. line2 = line2 .. expl[i] .. " "
  87. end
  88.  
  89. local label = vgui.Create("DLabel")
  90. label:SetParent(panel)
  91. label:SetPos(5, 5)
  92. label:SetText(name)
  93. label:SizeToContents()
  94. label:SetWide(panel:GetWide() - 30)
  95. -- label:A()
  96. label:SetVisible(true)
  97.  
  98. local label1 = vgui.Create("DLabel")
  99. label1:SetParent(panel)
  100. label1:SetPos(5, 5)
  101. label1:MoveBelow(label)
  102. label1:SetText(line2)
  103. label1:SizeToContents()
  104. label1:SetVisible(true)
  105.  
  106. local nextHeight = label:GetTall() > 78 and label:GetTall() - 78 or 0 // make panel taller for divider and buttons
  107. panel:SetTall(panel:GetTall() + nextHeight)
  108.  
  109. local divider = vgui.Create("Divider")
  110. divider:SetParent(panel)
  111. divider:SetPos(2, panel:GetTall() - 30)
  112. divider:SetSize(180, 2)
  113. divider:SetVisible(true)
  114.  
  115. local ybutton = vgui.Create("Button")
  116. ybutton:SetParent(panel)
  117. ybutton:SetPos(25, panel:GetTall() - 25)
  118. ybutton:AlignLeft(10)
  119. ybutton:SetSize(80, 20)
  120. ybutton:SetCommand("!")
  121. ybutton:SetText("Yes")
  122. ybutton:SetVisible(true)
  123. ybutton.DoClick = function()
  124. LocalPlayer():ConCommand("vote " .. voteid .. " 1\n")
  125. panel:Close()
  126. end
  127. ybutton:SetColor(color_white)
  128. ybutton:SetFont("DermaDefaultBold")
  129. ybutton.Paint = function(me)
  130. local w, h = me:GetSize()
  131. draw.RoundedBox(4, 0, 0, w, h, Color(0, 0, 0, 255))
  132. draw.RoundedBox(4, 1, 1, w - 2, h - 2, Color(27, 117, 36, 255))
  133.  
  134. if (me.Hovered) then
  135. draw.RoundedBox(4, 0, 0, w, h, Color(255, 255, 255, 100))
  136. end
  137. end
  138.  
  139. local nbutton = vgui.Create("Button")
  140. nbutton:SetParent(panel)
  141. nbutton:SetPos(70, panel:GetTall() - 25)
  142. nbutton:SetSize(80, 20)
  143. nbutton:AlignRight(25)
  144. nbutton:SetCommand("!")
  145. nbutton:SetText("No")
  146. nbutton:SetVisible(true)
  147. nbutton.DoClick = function()
  148. LocalPlayer():ConCommand("vote " .. voteid .. " 2\n")
  149. panel:Close()
  150. end
  151. nbutton:SetFont("DermaDefaultBold")
  152. nbutton:SetColor(color_white)
  153. nbutton.Paint = function(me)
  154. local w, h = me:GetSize()
  155. draw.RoundedBox(4, 0, 0, w, h, Color(0, 0, 0, 255))
  156. draw.RoundedBox(4, 1, 1, w - 2, h - 2, Color(175, 0, 0, 255))
  157.  
  158. if (me.Hovered) then
  159. draw.RoundedBox(4, 0, 0, w, h, Color(255, 255, 255, 100))
  160. end
  161. end
  162.  
  163. PanelNum = PanelNum + 140
  164. VoteVGUI[voteid .. "vote"] = panel
  165. end
  166. usermessage.Hook("DoVote", MsgDoVote)
  167.  
  168. local function KillVoteVGUI(msg)
  169. local id = msg:ReadString()
  170.  
  171. if VoteVGUI[id .. "vote"] and VoteVGUI[id .. "vote"]:IsValid() then
  172. VoteVGUI[id.."vote"]:Close()
  173.  
  174. end
  175. end
  176. usermessage.Hook("KillVoteVGUI", KillVoteVGUI)
  177.  
  178. local function MsgDoQuestion(msg)
  179. local _, chatY = chat.GetChatBoxPos()
  180. local question = msg:ReadString()
  181. local quesid = msg:ReadString()
  182. local timeleft = msg:ReadFloat()
  183. if timeleft == 0 then
  184. timeleft = 100
  185. end
  186. VoteQueues[quesid] = table.Count(VoteQueues) + 1
  187.  
  188. local OldTime = CurTime()
  189.  
  190. LocalPlayer():EmitSound("Town.d1_town_02_elevbell1", 100, 100)
  191. local panel = vgui.Create("DFrame")
  192. panel:SetPos(3, -50)
  193. panel:SetTitle("")
  194. panel:SetSize(220, 70)
  195. panel:SetSizable(false)
  196. panel.btnClose:SetVisible(false)
  197. panel.btnMaxim:SetVisible(false)
  198. panel.btnMinim:SetVisible(false)
  199. panel:SetDraggable(false)
  200. function panel:Close()
  201. VoteQueues[quesid] = nil
  202. for _, v in pairs (VoteQueues) do
  203. VoteQueues[_] = math.max(v - 1, 1)
  204. end
  205.  
  206. PanelNum = PanelNum - 70
  207. VoteVGUI[quesid .. "vote"] = nil
  208.  
  209. local num = 0
  210. for k,v in SortedPairs(VoteVGUI) do
  211. v:SetPos(3, chatY - 145 - num)
  212. num = num + 70
  213. end
  214.  
  215. for k,v in SortedPairs(QuestionVGUI) do
  216. v:SetPos(3, chatY - 145 - num)
  217. num = num + 300
  218. end
  219. self:Remove()
  220. end
  221. panel.Paint = function(me)
  222. local w, h = me:GetSize()
  223. draw.RoundedBox(4, 0, 0, w, h, Color(0, 0, 0, 255))
  224. draw.RoundedBox(4, 1, 1, w - 2, h - 2, Color(60, 60, 60, 255))
  225.  
  226. draw.RoundedBox(0, w - 12, 4, 8, h - 8, color_black)
  227. draw.RoundedBox(0, w - 11, 5, 6, h - 11, Color(25, 25, 25, 255))
  228.  
  229. local frac = (CurTime() - OldTime) / timeleft
  230. draw.RoundedBox(0, w - 11, 5 + h * frac, 6, h - h * frac - 10, Color(100, 100, 100, 255))
  231. end
  232.  
  233. function panel:Think()
  234. if timeleft - (CurTime() - OldTime) <= 0 then
  235. panel:Close()
  236. return
  237. end
  238.  
  239. panel.Pos = panel.Pos or -70
  240. panel.Pos = Lerp(5 * FrameTime(), panel.Pos, 3 + (VoteQueues[quesid] - 1) * 73)
  241.  
  242. panel:SetPos(3, panel.Pos)
  243. end
  244.  
  245. panel:SetKeyboardInputEnabled(false)
  246. panel:SetMouseInputEnabled(true)
  247. panel:SetVisible(true)
  248.  
  249. local expl = string.Explode("\n", question)
  250. local name = expl[1]
  251.  
  252. local line2 = ""
  253. for i = 2, #expl do
  254. line2 = line2 .. expl[i] .. " "
  255. end
  256.  
  257. local label = vgui.Create("DLabel")
  258. label:SetParent(panel)
  259. label:SetPos(5, 5)
  260. label:SetText(name)
  261. label:SizeToContents()
  262. label:SetWide(panel:GetWide() - 30)
  263. -- label:A()
  264. label:SetVisible(true)
  265.  
  266. local label1 = vgui.Create("DLabel")
  267. label1:SetParent(panel)
  268. label1:SetPos(5, 5)
  269. label1:MoveBelow(label)
  270. label1:SetText(line2)
  271. label1:SizeToContents()
  272. label1:SetVisible(true)
  273.  
  274. local nextHeight = label:GetTall() > 78 and label:GetTall() - 78 or 0 // make panel taller for divider and buttons
  275. panel:SetTall(panel:GetTall() + nextHeight)
  276.  
  277. local divider = vgui.Create("Divider")
  278. divider:SetParent(panel)
  279. divider:SetPos(2, panel:GetTall() - 30)
  280. divider:SetSize(180, 2)
  281. divider:SetVisible(true)
  282.  
  283. local ybutton = vgui.Create("Button")
  284. ybutton:SetParent(panel)
  285. ybutton:SetPos(25, panel:GetTall() - 25)
  286. ybutton:AlignLeft(10)
  287. ybutton:SetSize(80, 20)
  288. ybutton:SetCommand("!")
  289. ybutton:SetText("Yes")
  290. ybutton:SetVisible(true)
  291. ybutton.DoClick = function()
  292. LocalPlayer():ConCommand("ans " .. quesid .. " 1\n")
  293. panel:Close()
  294. end
  295. ybutton:SetColor(color_white)
  296. ybutton:SetFont("DermaDefaultBold")
  297. ybutton.Paint = function(me)
  298. local w, h = me:GetSize()
  299. draw.RoundedBox(4, 0, 0, w, h, Color(0, 0, 0, 255))
  300. draw.RoundedBox(4, 1, 1, w - 2, h - 2, Color(27, 117, 36, 255))
  301.  
  302. if (me.Hovered) then
  303. draw.RoundedBox(4, 0, 0, w, h, Color(255, 255, 255, 100))
  304. end
  305. end
  306.  
  307. local nbutton = vgui.Create("Button")
  308. nbutton:SetParent(panel)
  309. nbutton:SetPos(70, panel:GetTall() - 25)
  310. nbutton:SetSize(80, 20)
  311. nbutton:AlignRight(25)
  312. nbutton:SetCommand("!")
  313. nbutton:SetText("No")
  314. nbutton:SetVisible(true)
  315. nbutton.DoClick = function()
  316. LocalPlayer():ConCommand("ans " .. quesid .. " 2\n")
  317. panel:Close()
  318. end
  319. nbutton:SetFont("DermaDefaultBold")
  320. nbutton:SetColor(color_white)
  321. nbutton.Paint = function(me)
  322. local w, h = me:GetSize()
  323. draw.RoundedBox(4, 0, 0, w, h, Color(0, 0, 0, 255))
  324. draw.RoundedBox(4, 1, 1, w - 2, h - 2, Color(175, 0, 0, 255))
  325.  
  326. if (me.Hovered) then
  327. draw.RoundedBox(4, 0, 0, w, h, Color(255, 255, 255, 100))
  328. end
  329. end
  330.  
  331. PanelNum = PanelNum + 140
  332. VoteVGUI[quesid .. "vote"] = panel
  333. end
  334. usermessage.Hook("DoQuestion", MsgDoQuestion)
  335.  
  336. local function KillQuestionVGUI(msg)
  337. local id = msg:ReadString()
  338.  
  339. if QuestionVGUI[id .. "ques"] and QuestionVGUI[id .. "ques"]:IsValid() then
  340. QuestionVGUI[id .. "ques"]:Close()
  341. end
  342. end
  343. usermessage.Hook("KillQuestionVGUI", KillQuestionVGUI)
  344.  
  345. local function DoVoteAnswerQuestion(ply, cmd, args)
  346. if not args[1] then return end
  347.  
  348. local vote = 2
  349. if tonumber(args[1]) == 1 or string.lower(args[1]) == "yes" or string.lower(args[1]) == "true" then vote = 1 end
  350.  
  351. for k,v in pairs(VoteVGUI) do
  352. if ValidPanel(v) then
  353. local ID = string.sub(k, 1, -5)
  354. VoteVGUI[k]:Close()
  355. RunConsoleCommand("vote", ID, vote)
  356. return
  357. end
  358. end
  359.  
  360. for k,v in pairs(QuestionVGUI) do
  361. if ValidPanel(v) then
  362. local ID = string.sub(k, 1, -5)
  363. QuestionVGUI[k]:Close()
  364. RunConsoleCommand("ans", ID, vote)
  365. return
  366. end
  367. end
  368. end
  369. concommand.Add("rp_vote", DoVoteAnswerQuestion)
  370.  
  371. local function DoLetter(msg)
  372. LetterWritePanel = vgui.Create("Frame")
  373. LetterWritePanel:SetPos(ScrW() / 2 - 75, ScrH() / 2 - 100)
  374. LetterWritePanel:SetSize(150, 200)
  375. LetterWritePanel:SetMouseInputEnabled(true)
  376. LetterWritePanel:SetKeyboardInputEnabled(true)
  377. LetterWritePanel:SetVisible(true)
  378. end
  379. usermessage.Hook("DoLetter", DoLetter)
  380.  
  381. //Modify this
  382. local Colors = {
  383. //Main menu
  384. F4MenuBackground = Color(0,105,31,80),
  385. F4MenuBorder = Color(60,60,60,160),
  386. LogoCardBackground = Color(30,16,36,180),
  387. LogoCardTop = Color(255,255,255,255),
  388. LogoCardBottom = Color(20,250,60,255),
  389. CanvasBackground = Color(26,26,26,220),
  390. //Actions tab
  391. ButtonBackground = Color(201,201,201,255),
  392. ButtonText = Color(120,120,120,255),
  393. CategoryBackground = Color(151,151,151,255),
  394. //Jobs tab
  395. JobOutlineHover = Color(255,255,255),
  396. JobOutlinePressed = Color(10,10,255),
  397. //Shop tab
  398. ShopItemBackground = Color(201,201,201,255),
  399. ShopDescriptionBackground = Color(0,0,0,200),
  400. //Shared between tabs
  401. TabActive = Color(26,26,26,220),
  402. TabInactive = Color(60,60,60,220),
  403. TabTitleFront = Color(255,255,255,255),
  404. TabTitleShadow = Color(0,0,0,255),
  405. }
  406. local Texts = {
  407. //Menu
  408. LogoCardTop = 'PunchGaming',
  409. LogoCardBottom = 'Main Menu',
  410. //Tab titles
  411. ActionsTabTitle = 'Actions',
  412. JobsTabTitle = 'Jobs',
  413. ShopTabTitle = 'Shop',
  414. ForumTabTitle = 'Rules',
  415. //Some localizations
  416. DescriptionTitle = 'Description:',
  417. WeaponsNone = "This job has no weapons.",
  418. WeaponsSpecial = "Weapons:",
  419. CurrentTeam = 'Current: ',
  420. //Some system settings - no modifications needed, really
  421. TabTitleFont = 'F4TabTitle',
  422. ButtonFont = 'DermaDefaultBold',
  423. DarkRPCommand = 'say',
  424. }
  425. local Materials = {
  426. GradientNormal = Material('gui/gradient'),
  427. GradientUp = Material('gui/gradient_up'),
  428. GradientDown = Material('gui/gradient_down'),
  429. GradientCenter = Material('gui/center_gradient'),
  430. ActionsButton = Material('icon16/star.png'),
  431. JobsButton = Material('icon16/user_suit.png'),
  432. ShopButton = Material('icon16/cart.png'),
  433. ForumButton = Material('icon16/heart.png'),
  434. }
  435.  
  436. //Command workaround
  437. local function RunCmd(...)
  438. local arg = {...}
  439. if Texts.DarkRPCommand:lower():find('say') then
  440. arg = table.concat(arg,' ')
  441. else
  442. arg = table.concat(arg,'" "')
  443. end
  444. RunConsoleCommand(Texts.DarkRPCommand,arg)
  445. end
  446.  
  447. //This is what creates the layout
  448. local function CreateMenu()
  449. if F4Menu and IsValid(F4Menu) then
  450. F4Menu:Remove()
  451. end
  452.  
  453. local LogoCard,Canvas,TopBar
  454. local ActionsButton,ActionsTab
  455. local JobsButton,JobsTab
  456. local ShopButton,ShopTab
  457. local DonateButton,DonateTab
  458.  
  459. F4Menu = vgui.Create('DFrame')
  460. F4Menu:SetSize(800,555)
  461. F4Menu:Center()
  462. F4Menu:MakePopup()
  463. F4Menu:ShowCloseButton(true)
  464. F4Menu.btnMaxim:SetVisible( false )
  465. F4Menu.btnMinim:SetVisible( false )
  466. F4Menu:SetDeleteOnClose(false)
  467. F4Menu:ParentToHUD()
  468. F4Menu:SetDraggable(false)
  469. F4Menu:SetSizable(false)
  470. F4Menu:SetTitle('')
  471. F4Menu.Tabs = {}
  472. function F4Menu:OpenTab(Button)
  473. if Button == nil then
  474. if self.OpenedTab and self.OpenedTab:IsValid() then
  475. Button = self.OpenedTab
  476. else
  477. Button = table.GetFirstKey(self.Tabs)
  478. end
  479. end
  480. if self.Tabs[Button] and IsValid(self.Tabs[Button]) then
  481. self.OpenedTab = Button
  482. for k,v in pairs(self.Tabs) do
  483. k.Toggled = false
  484. v:SetVisible(false)
  485. end
  486. self.Tabs[Button]:SetVisible(true)
  487. self.Tabs[Button]:Refresh()
  488. Button.Toggled = true
  489. end
  490. end
  491. function F4Menu:Paint(w,h)
  492. surface.SetDrawColor(Colors.F4MenuBackground)
  493. surface.DrawRect(0,0,w,h)
  494. surface.SetDrawColor(Colors.F4MenuBorder)
  495. surface.DrawOutlinedRect(0,0,w,h)
  496. end
  497.  
  498. LogoCard = vgui.Create('DPanel',F4Menu)
  499. LogoCard:SetPos(5,5)
  500. LogoCard:SetSize(175,70)
  501. function LogoCard:Paint(w,h)
  502. draw.RoundedBox(4,0,0,w,h,Colors.LogoCardBackground)
  503. draw.SimpleText(Texts.LogoCardTop,'DermaLarge',5,5,Colors.LogoCardTop)
  504. draw.SimpleText(Texts.LogoCardBottom,'DermaLarge',5,35,Colors.LogoCardBottom)
  505. end
  506. F4Menu.LogoCard = LogoCard
  507.  
  508. Canvas = vgui.Create('DPanel',F4Menu)
  509. Canvas:SetPos(5,LogoCard.y+LogoCard:GetTall()+5)
  510. Canvas:SetSize(F4Menu:GetWide()-10,F4Menu:GetTall()-(LogoCard.y+LogoCard:GetTall()+10))
  511. function Canvas:Paint(w,h)
  512. draw.RoundedBox(8,0,0,w,h,Colors.CanvasBackground)
  513. end
  514. F4Menu.Canvas = Canvas
  515. end
  516.  
  517. //Options stuff
  518. local function CreateButton(w,text,icon,doclick)
  519. text = tostring(text)
  520. w = tonumber(w) or 2
  521. icon = icon and Material(icon) or false
  522. doclick = doclick or function()end
  523. w = w*185 + (w-1)*5
  524.  
  525. local button = vgui.Create('DButton')
  526. button:SetSize(w,45)
  527. button.Paint = function(self,w,h)
  528. draw.RoundedBox(4,0,0,w,h,Colors.ButtonBackground)
  529. if icon then
  530. surface.SetDrawColor(Color(200,200,200,255))
  531. surface.SetMaterial(icon)
  532. surface.DrawTexturedRect(8,h/2-8,16,16)
  533. draw.SimpleText(text,Texts.ButtonFont,8+w/2,h/2,Colors.ButtonText,TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER)
  534. else
  535. draw.SimpleText(text,Texts.ButtonFont,w/2,h/2,Colors.ButtonText,TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER)
  536. end
  537. return true
  538. end
  539. button.DoClick = doclick
  540. return button
  541. end
  542. local function GetOptions(type,col)
  543. type = tostring(type)
  544. col = col or Color(151,151,151,255)
  545. local Actions = vgui.Create("DPanelList")
  546. Actions:SetAutoSize(true)
  547. Actions:SetPadding(10)
  548. Actions:SetSpacing(5)
  549. Actions:EnableHorizontal(true)
  550. local Category = vgui.Create("DCollapsibleCategory")
  551. Category:SetLabel(type)
  552. Category:SetContents(Actions)
  553. Category.Paint = function(self,w,h)
  554. draw.RoundedBox(4,0,0,w,h,col)
  555. draw.RoundedBox(4,0,0,w,h,Color(151,151,151,100))
  556. end
  557. if type == 'general' then
  558. Category:SetLabel('General')
  559.  
  560. Actions:AddItem(CreateButton(2,
  561. "Drop Money",
  562. 'icon16/money.png',
  563. function()
  564. Derma_StringRequest("Amount of money", "How much money do you want to drop?", "", function(a) RunCmd("/dropmoney", tostring(a)) end)
  565. end))
  566. Actions:AddItem(CreateButton(2,
  567. string.format("Donate"),
  568. 'icon16/heart.png',
  569. function()
  570. RunCmd("!donate")
  571. F4Menu:Close()
  572. end))
  573. Actions:AddItem(CreateButton(2,
  574. string.format("Call an admin"),
  575. 'icon16/shield.png',
  576. function()
  577. RunCmd("@ Admin to me i need help")
  578. F4Menu:Close()
  579. end))
  580. Actions:AddItem(CreateButton(2,
  581. "Drop Weapon",
  582. 'icon16/box.png',
  583. function()
  584. RunCmd("/drop")
  585. end))
  586. elseif type == 'roleplay' then
  587. Category:SetLabel('Roleplay actions')
  588. Actions:AddItem(CreateButton(1,
  589. 'Change RP Name',
  590. 'icon16/vcard_edit.png',
  591. function()
  592. Derma_StringRequest("Roleplay name", "What do you want to change your roleplay name to?", LocalPlayer():Name() or "", function(a) RunCmd("/rpname", tostring(a)) end)
  593. end))
  594. Actions:AddItem(CreateButton(1,
  595. 'Custom Job Title',
  596. 'icon16/vcard_edit.png',
  597. function()
  598. Derma_StringRequest("Job title", "What do you want to change your job title to?", LocalPlayer().DarkRPVars.job or "", function(a) RunCmd("/job", tostring(a)) end)
  599. end))
  600. Actions:AddItem(CreateButton(1,
  601. 'Demote A Player',
  602. 'icon16/user_delete.png',
  603. function()
  604. local menu = DermaMenu()
  605. for _,ply in pairs(player.GetAll()) do
  606. if ply ~= LocalPlayer() then
  607. menu:AddOption(ply:Nick(), function()
  608. Derma_StringRequest("Demote reason", "Why would you demote "..ply:Nick().."?", nil,function(a)RunCmd("/demote", tostring(ply:UserID()).." ".. a)end, function() end )
  609. end)
  610. end
  611. end
  612. menu:Open()
  613. end))
  614. Actions:AddItem(CreateButton(1,
  615. 'Sell All Doors',
  616. 'icon16/book_delete.png',
  617. function() RunCmd("/unownalldoors") end))
  618. elseif type == 'police' then
  619. col = team.GetColor(TEAM_POLICE)
  620. Category:SetLabel('Police')
  621. Actions:AddItem(CreateButton(1,
  622. 'Request Warrant',
  623. 'icon16/script_error.png',
  624. function()
  625. local menu = DermaMenu()
  626. for _,ply in pairs(player.GetAll()) do
  627. if ply ~= LocalPlayer() then
  628. menu:AddOption(ply:Nick(), function()
  629. Derma_StringRequest("Warrant", "Why would you warrant "..ply:Nick().."?", nil,function(a)RunCmd("/warrant", tostring(ply:UserID()).." ".. a)end, function() end )
  630. end)
  631. end
  632. end
  633. menu:Open()
  634. end))
  635. Actions:AddItem(CreateButton(1,
  636. 'Make Wanted',
  637. 'icon16/group_error.png',
  638. function()
  639. local menu = DermaMenu()
  640. for _,ply in pairs(player.GetAll()) do
  641. if ply ~= LocalPlayer() then
  642. menu:AddOption(ply:Nick(), function()
  643. Derma_StringRequest("Warrant", "Why would you make "..ply:Nick().." wanted?", nil,function(a)RunCmd("/wanted", tostring(ply:UserID()).." ".. a)end, function() end )
  644. end)
  645. end
  646. end
  647. menu:Open()
  648. end))
  649. Actions:AddItem(CreateButton(1,
  650. 'Remove Wanted',
  651. 'icon16/group_add.png',
  652. function()
  653. local menu = DermaMenu()
  654. for _,ply in pairs(player.GetAll()) do
  655. if ply ~= LocalPlayer() then
  656. menu:AddOption(ply:Nick(), function()
  657. RunCmd("/unwanted", tostring(ply:UserID()))
  658. end)
  659. end
  660. end
  661. menu:Open()
  662. end))
  663. if LocalPlayer():Team() == TEAM_CHIEF or LocalPlayer():IsAdmin() then
  664. Actions:AddItem(CreateButton(1,
  665. 'Set Jail Position',
  666. 'icon16/accept.png',
  667. function() RunCmd("/setjailpos") end))
  668. Actions:AddItem(CreateButton(1,
  669. 'Add Jail Position',
  670. 'icon16/add.png',
  671. function() RunCmd("/addjailpos") end))
  672. end
  673. elseif type == 'mayor' then
  674. col = team.GetColor(TEAM_MAYOR)
  675. Category:SetLabel('Mayor')
  676. Actions:AddItem(CreateButton(1,
  677. 'Initiate lockdown',
  678. 'icon16/bell_add.png',
  679. function() RunCmd("/lockdown") end))
  680. Actions:AddItem(CreateButton(1,
  681. 'Stop Lockdown',
  682. 'icon16/bell_delete.png',
  683. function() RunCmd("/unlockdown") end))
  684. Actions:AddItem(CreateButton(1,
  685. 'Initiate Lottery',
  686. 'icon16/money.png',
  687. function() RunCmd("/lottery") end))
  688. Actions:AddItem(CreateButton(1,
  689. 'Place Law Board',
  690. 'icon16/application.png',
  691. function() RunCmd("/placelaws") end))
  692. Actions:AddItem(CreateButton(1,
  693. 'Add Law',
  694. 'icon16/application_add.png',
  695. function()
  696. Derma_StringRequest("Add a law", "Type the law you would like to add here.", "", function(law)
  697. RunCmd("/addlaw ", law)
  698. end)
  699. end))
  700. Actions:AddItem(CreateButton(1,
  701. 'Remove Law',
  702. 'icon16/application_delete.png',
  703. function()
  704. Derma_StringRequest("Remove a law", "Enter the number of the law you would like to remove here.", "", function(num)
  705. RunCmd("/removelaw", num)
  706. end)
  707. end))
  708. elseif type == 'mobboss' then
  709. local Team = LocalPlayer():Team()
  710. col = Team == TEAM_MOB and team.GetColor(TEAM_MOB) or Team == TEAM_BDL and team.GetColor(TEAM_BDL) or col
  711. Category:SetLabel('Mob boss')
  712. Actions:AddItem(CreateButton(1,
  713. 'Set Agenda',
  714. 'icon16/application_view_detail.png',
  715. function()
  716. Derma_StringRequest("Set agenda", "What text would you like to change agenda to?", LocalPlayer().DarkRPVars.agenda or "", function(a)
  717. RunCmd("/agenda", tostring(a))
  718. end)
  719. end))
  720. end
  721. return Category
  722. end
  723.  
  724. //Stuff related to teams
  725. local function GetDescription(team)
  726. local Team = RPExtraTeams[team]
  727. if !Team then return false end
  728. local description = Texts.DescriptionTitle
  729. description = description.."\n"..Team.description
  730. description = description.."\n\n"
  731. local weps = ""
  732. if #Team.weapons > 0 then
  733. weps = Texts.WeaponsSpecial
  734. for k,v in pairs(Team.weapons) do
  735. local class = weapons.Get(v)
  736. if class then
  737. weps = weps.."\n* "..(class.PrintName or v)
  738. end
  739. end
  740. else
  741. weps = Texts.WeaponsNone
  742. end
  743. description = description..weps
  744. return description
  745. end
  746. local function GetDisplayTeam(team)
  747. local Team = RPExtraTeams[team]
  748. if !Team then return false end
  749. Team = table.Copy(Team)
  750. if LocalPlayer():Team() == team then
  751. Team.name = Texts.CurrentTeam..Team.name
  752. end
  753. Team.desc_full = GetDescription(team)
  754. if type(Team.model) == "table" then
  755. Team.model = table.Random(Team.model)
  756. end
  757. return Team
  758. end
  759.  
  760. //Tabs stuff
  761. local function AddActionsTab()
  762. local ActionList
  763. local ActionsButton = vgui.Create('DButton',F4Menu)
  764. ActionsButton:SetPos(280,F4Menu.Canvas.y-35)
  765. ActionsButton:SetSize(110,35)
  766. ActionsButton.Icon = Materials.ActionsButton
  767. ActionsButton.Text = Texts.ActionsTabTitle
  768. ActionsButton.DoClick = function(self) F4Menu:OpenTab(self) end
  769. ActionsButton.Paint = function(self,w,h)
  770. local ry,rh
  771. if self.Toggled then
  772. ry,rh = 0,h
  773. draw.RoundedBoxEx(4,0,ry,w,rh,Colors.TabActive,true,true)
  774. else
  775. ry,rh = 5,h-5
  776. draw.RoundedBoxEx(4,0,ry,w,rh,Colors.TabInactive,true,true)
  777. end
  778. surface.SetDrawColor(Color(255,255,255,255))
  779. surface.SetMaterial(self.Icon)
  780. surface.DrawTexturedRect(8,ry+rh/2-8,16,16)
  781. draw.SimpleText(self.Text,Texts.TabTitleFont,32+3,ry+rh/2+3,Colors.TabTitleShadow,nil,TEXT_ALIGN_CENTER)
  782. draw.SimpleText(self.Text,Texts.TabTitleFont,32,ry+rh/2,Colors.TabTitleFront,nil,TEXT_ALIGN_CENTER)
  783. return true
  784. end
  785.  
  786. local ActionsTab = vgui.Create('DPanel',F4Menu.Canvas)
  787. ActionsTab:SetSize(F4Menu.Canvas:GetSize())
  788. ActionsTab.Paint = function()end
  789. ActionsTab.Refresh = function(self)
  790. ActionList:Clear()
  791. ActionList:AddItem(GetOptions('general'))
  792. ActionList:AddItem(GetOptions('roleplay'))
  793. local team = LocalPlayer():Team()
  794. if team == TEAM_MAYOR then
  795. ActionList:AddItem(GetOptions('mayor'))
  796. ActionList:AddItem(GetOptions('police'))
  797. elseif table.HasValue({TEAM_SECRETS, TEAM_CHIEF, TEAM_POLICE, TEAM_MAYOR, TEAM_SWAT, TEAM_SPEC, TEAM_CHIEFPLUS, TEAM_SWATPLUS, TEAM_POLICEPLUS},LocalPlayer():Team())
  798. then
  799. ActionList:AddItem(GetOptions('police'))
  800. elseif team == TEAM_MOB or team == TEAM_BDL then
  801. ActionList:AddItem(GetOptions('mobboss'))
  802. end
  803. end
  804.  
  805. ActionList = vgui.Create('DPanelList',ActionsTab)
  806. ActionList:SetPos(5,5)
  807. ActionList:SetSize(ActionsTab:GetWide()-10,ActionsTab:GetTall()-10)
  808. ActionList:EnableVerticalScrollbar(true)
  809. ActionList:SetSpacing(5)
  810.  
  811. F4Menu.Tabs[ActionsButton] = ActionsTab
  812. F4Menu:OpenTab(ActionsButton)
  813. return ActionsButton
  814. end
  815. local function AddJobsTab()
  816. local JobList,JobPreview,JobsTab,JobsButton
  817. JobsButton = vgui.Create('DButton',F4Menu)
  818. JobsButton:SetPos(410,F4Menu.Canvas.y-35)
  819. JobsButton:SetSize(110,35)
  820. JobsButton.Icon = Materials.JobsButton
  821. JobsButton.Text = Texts.JobsTabTitle
  822. JobsButton.DoClick = function(self) F4Menu:OpenTab(self) end
  823. JobsButton.Paint = function(self,w,h)
  824. local ry,rh
  825. if self.Toggled then
  826. ry,rh = 0,h
  827. draw.RoundedBoxEx(4,0,ry,w,rh,Colors.TabActive,true,true)
  828. else
  829. ry,rh = 5,h-5
  830. draw.RoundedBoxEx(4,0,ry,w,rh,Colors.TabInactive,true,true)
  831. end
  832. surface.SetDrawColor(Color(255,255,255,255))
  833. surface.SetMaterial(self.Icon)
  834. surface.DrawTexturedRect(8,ry+rh/2-8,16,16)
  835. draw.SimpleText(self.Text,Texts.TabTitleFont,32+3,ry+rh/2+3,Colors.TabTitleShadow,nil,TEXT_ALIGN_CENTER)
  836. draw.SimpleText(self.Text,Texts.TabTitleFont,32,ry+rh/2,Colors.TabTitleFront,nil,TEXT_ALIGN_CENTER)
  837. return true
  838. end
  839.  
  840. local PAINT_JOB = function(self,w,h)
  841. draw.RoundedBox(4,0,0,w,h,self.m_colText)
  842. if self.Hovered then
  843. draw.RoundedBox(4,4,4,w-8,h-8,!self.Depressed and Colors.JobOutlineHover or Colors.JobOutlinePressed)
  844. draw.RoundedBox(4,6,6,w-12,h-12,self.m_colText)
  845. end
  846. draw.SimpleText(self:GetText(),Texts.TabTitleFont,70,h/2,nil,nil,TEXT_ALIGN_CENTER)
  847. return true
  848. end
  849. local DOCLICK_JOB = function(self,w,h)
  850. local Team = JobPreview.Team
  851. if Team.vote then
  852. if ((Team.admin == 0 and LocalPlayer():IsAdmin()) or (Team.admin == 1 and LocalPlayer():IsSuperAdmin())) then
  853. local menu = DermaMenu()
  854. menu:AddOption("Vote", function() RunCmd("/vote"..Team.command) F4Menu:Close() end)
  855. menu:AddOption("Do not vote", function() RunCmd("/"..Team.command) F4Menu:Close() end)
  856. menu:Open()
  857. else
  858. RunCmd("/vote" .. Team.command)
  859. F4Menu:Close()
  860. end
  861. else
  862. RunCmd("/" .. Team.command)
  863. F4Menu:Close()
  864. end
  865. end
  866. JobsTab = vgui.Create('DPanel',F4Menu.Canvas)
  867. JobsTab:SetSize(F4Menu.Canvas:GetSize())
  868. JobsTab.Paint = function()end
  869. JobsTab.Refresh = function(self)
  870. local ply = LocalPlayer()
  871. local pt = ply:Team()
  872. local width = (JobList:GetWide()-25)/2
  873. JobList:Clear()
  874. JobPreview.Team = GetDisplayTeam(LocalPlayer():Team())
  875. JobPreview:Refresh()
  876.  
  877. for k,v in pairs(RPExtraTeams) do
  878. local show = true
  879. if pt == k then
  880. show = false
  881. elseif v.admin == 1 and not ply:IsAdmin() then
  882. show = false
  883. end
  884. if v.admin > 1 and not ply:IsSuperAdmin() then
  885. show = false
  886. end
  887. if v.customCheck and not v.customCheck(ply) then
  888. show = false
  889. end
  890. if (type(v.NeedToChangeFrom) == "number" and pt ~= v.NeedToChangeFrom) or (type(v.NeedToChangeFrom) == "table" and not table.HasValue(v.NeedToChangeFrom, pt)) then
  891. show = false
  892. end
  893.  
  894. if show then
  895. local model = v.model
  896. if type(model) == "table" then
  897. model = table.Random(model)
  898. end
  899.  
  900. local button = vgui.Create('DButton')
  901. button:SetSize(width,66)
  902. button:SetColor(team.GetColor(k))
  903. button:SetText(v.name)
  904. button.Paint = PAINT_JOB
  905. button.DoClick = DOCLICK_JOB
  906. button.OnCursorEntered = function(self)
  907. JobPreview.Team = GetDisplayTeam(self.Team)
  908. JobPreview:Refresh()
  909. end
  910. button:SetTooltip('Press to join job')
  911.  
  912. local icon = vgui.Create('SpawnIcon',button)
  913. icon:SetSize(64,64)
  914. icon:SetPos(1,1)
  915. icon:SetModel(model)
  916. icon:SetMouseInputEnabled(false)
  917. icon.PaintOver = function()end
  918. icon.DoClick = function()end
  919.  
  920. button.Team = k
  921.  
  922. JobList:AddItem(button)
  923. end
  924. end
  925. end
  926.  
  927. JobList = vgui.Create('DPanelList',JobsTab)
  928. JobList:SetPos(5,5)
  929. JobList:SetSize((JobsTab:GetWide()-15)*.6,JobsTab:GetTall()-10)
  930. JobList:EnableHorizontal(true)
  931. JobList:EnableVerticalScrollbar(true)
  932. JobList:SetSpacing(10)
  933.  
  934. JobPreview = vgui.Create('DPanelList',JobsTab)
  935. JobPreview:SetPos(10+JobList:GetWide(),5)
  936. JobPreview:SetSize((JobsTab:GetWide()-15)*.4,JobsTab:GetTall()-10)
  937. JobPreview.Paint = function(self,w,h)
  938. draw.RoundedBox(4,0,0,w,h,Color(120,120,120,45))
  939. if self.Team then
  940. draw.RoundedBox(4,0,0,w,50,self.Team.color)
  941. draw.SimpleText(self.Team.name,Texts.TabTitleFont,w/2,20,nil,TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER)
  942. draw.RoundedBox(4,0,40,w,h-40,Color(220,220,220))
  943. end
  944. end
  945. JobPreview.Refresh = function(self)
  946. local enabled = tobool(self.Team)
  947. self.Description:SetVisible(enabled)
  948. if enabled then
  949. self.Description:SetText(self.Team.desc_full)
  950. end
  951. end
  952.  
  953. JobPreview.Description = vgui.Create('DTextEntry',JobPreview)
  954. JobPreview.Description:SetPos(5,45)
  955. JobPreview.Description:SetSize(JobPreview:GetWide()-10,JobPreview:GetTall()-50)
  956. JobPreview.Description:SetMultiline(true)
  957. JobPreview.Description:SetEditable(false)
  958. JobPreview.Description:SetDrawBackground(false)
  959.  
  960. F4Menu.Tabs[JobsButton] = JobsTab
  961. return JobsButton
  962. end
  963. local function AddShopTab()
  964. local ItemList
  965. local ShopButton = vgui.Create('DButton',F4Menu)
  966. ShopButton:SetPos(540,F4Menu.Canvas.y-35)
  967. ShopButton:SetSize(110,35)
  968. ShopButton.Icon = Materials.ShopButton
  969. ShopButton.Text = Texts.ShopTabTitle
  970. ShopButton.DoClick = function(self) F4Menu:OpenTab(self) end
  971. ShopButton.Paint = function(self,w,h)
  972. local ry,rh
  973. if self.Toggled then
  974. ry,rh = 0,h
  975. draw.RoundedBoxEx(4,0,ry,w,rh,Colors.TabActive,true,true)
  976. else
  977. ry,rh = 5,h-5
  978. draw.RoundedBoxEx(4,0,ry,w,rh,Colors.TabInactive,true,true)
  979. end
  980. surface.SetDrawColor(Color(255,255,255,255))
  981. surface.SetMaterial(self.Icon)
  982. surface.DrawTexturedRect(8,ry+rh/2-8,16,16)
  983. draw.SimpleText(self.Text,Texts.TabTitleFont,32+3,ry+rh/2+3,Colors.TabTitleShadow,nil,TEXT_ALIGN_CENTER)
  984. draw.SimpleText(self.Text,Texts.TabTitleFont,32,ry+rh/2,Colors.TabTitleFront,nil,TEXT_ALIGN_CENTER)
  985. return true
  986. end
  987.  
  988. local ShopTab = vgui.Create('DPanel',F4Menu.Canvas)
  989. ShopTab:SetSize(F4Menu.Canvas:GetSize())
  990. ShopTab.Paint = function()end
  991. ShopTab.Refresh = function()
  992. ItemList:Clear()
  993. if #CustomShipments > 0 then
  994. local WepCat = vgui.Create("DCollapsibleCategory")
  995. WepCat.Paint = function(self,w,h) draw.RoundedBox(4,0,0,w,h,Colors.CategoryBackground) end
  996. WepCat:SetLabel("Weapons")
  997. local WepPanel = vgui.Create("DPanelList")
  998. WepPanel:SetSize(470, 100)
  999. WepPanel:SetAutoSize(true)
  1000. WepPanel:EnableHorizontal(true)
  1001. WepPanel:SetPadding(5)
  1002. WepPanel:SetSpacing(5)
  1003. local function AddWepIcon(Model, description, command)
  1004. local button = vgui.Create("DButton")
  1005. button:SetSize(80,80)
  1006. button.Paint = function(self,w,h)
  1007. draw.RoundedBox(4,0,0,w,h,Colors.ShopItemBackground)
  1008. return true
  1009. end
  1010. button.PaintOver = function(self,w,h)
  1011. if self.Hovered then
  1012. draw.RoundedBoxEx(4,0,h-20,w,20,Colors.ShopDescriptionBackground,false,false,true,true)
  1013. draw.SimpleText(description,'DefaultSmall',w/2,h-10,nil,TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER)
  1014. end
  1015. end
  1016. button.DoClick = function() RunCmd(command) end
  1017. button:SetToolTip(description)
  1018. local icon = vgui.Create("SpawnIcon",button)
  1019. icon:InvalidateLayout( true )
  1020. icon:SetModel(Model)
  1021. icon:SetSize(64, 64)
  1022. icon:SetPos(8,8)
  1023. icon:SetMouseInputEnabled(false)
  1024. WepPanel:AddItem(button)
  1025. end
  1026.  
  1027. local shown = 0
  1028. for k,v in pairs(CustomShipments) do
  1029. if (v.seperate and (not GAMEMODE.Config.restrictbuypistol or
  1030. (GAMEMODE.Config.restrictbuypistol and (not v.allowed[1] or table.HasValue(v.allowed, LocalPlayer():Team())))))
  1031. and (not v.customCheck or v.customCheck and v.customCheck(LocalPlayer())) then
  1032. AddWepIcon(v.model, v.name..': '.. CUR .. (v.pricesep or ""), "/buy "..v.name)
  1033. shown = shown + 1
  1034. end
  1035. end
  1036.  
  1037. for k,v in pairs(GAMEMODE.AmmoTypes) do
  1038. if not v.customCheck or v.customCheck(LocalPlayer()) then
  1039. AddWepIcon(v.model, v.name..': '.. CUR .. v.price, "/buyammo " .. v.ammoType)
  1040. shown = shown + 1
  1041. end
  1042. end
  1043. if shown > 0 then
  1044. WepCat:SetContents(WepPanel)
  1045. ItemList:AddItem(WepCat)
  1046. else
  1047. WepPanel:Remove()
  1048. WepCat:Remove()
  1049. end
  1050. end
  1051. if #DarkRPEntities > 0 then
  1052. local EntCat = vgui.Create("DCollapsibleCategory")
  1053. EntCat.Paint = function(self,w,h) draw.RoundedBox(4,0,0,w,h,Colors.CategoryBackground) end
  1054. EntCat:SetLabel("Entities")
  1055. local EntPanel = vgui.Create("DPanelList")
  1056. EntPanel:SetSize(470, 200)
  1057. EntPanel:SetAutoSize(true)
  1058. EntPanel:EnableHorizontal(true)
  1059. EntPanel:SetPadding(5)
  1060. EntPanel:SetSpacing(5)
  1061. local function AddEntIcon(Model, description, command)
  1062. local button = vgui.Create("DButton")
  1063. button:SetSize(80,80)
  1064. button.Paint = function(self,w,h)
  1065. draw.RoundedBox(4,0,0,w,h,Colors.ButtonBackground)
  1066. return true
  1067. end
  1068. button.PaintOver = function(self,w,h)
  1069. if self.Hovered then
  1070. draw.RoundedBoxEx(4,0,h-20,w,20,Color(0,0,0,200),false,false,true,true)
  1071. draw.SimpleText(description,'DefaultSmall',w/2,h-10,nil,TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER)
  1072. end
  1073. end
  1074. button.DoClick = function() RunCmd(command) end
  1075. button:SetToolTip(description)
  1076. local icon = vgui.Create("SpawnIcon",button)
  1077. icon:InvalidateLayout( true )
  1078. icon:SetModel(Model)
  1079. icon:SetSize(64, 64)
  1080. icon:SetPos(8,8)
  1081. icon:SetMouseInputEnabled(false)
  1082. EntPanel:AddItem(button)
  1083. end
  1084.  
  1085. local shown = 0
  1086. for k,v in pairs(DarkRPEntities) do
  1087. if not v.allowed or (type(v.allowed) == "table" and table.HasValue(v.allowed, LocalPlayer():Team()))
  1088. and (not v.customCheck or (v.customCheck and v.customCheck(LocalPlayer()))) then
  1089. local cmdname = string.gsub(v.ent, " ", "_")
  1090.  
  1091. AddEntIcon(v.model, v.name ..": " .. CUR .. v.price, v.cmd)
  1092. shown = shown + 1
  1093. end
  1094. end
  1095.  
  1096. if FoodItems and (GAMEMODE.Config.foodspawn or LocalPlayer():Team() == TEAM_COOK) and (GAMEMODE.Config.hungermod or LocalPlayer():Team() == TEAM_COOK) then
  1097. for k,v in pairs(FoodItems) do
  1098. AddEntIcon(v.model, k .. ": " .. CUR .. "15", "/buyfood "..k)
  1099. shown = shown + 1
  1100. end
  1101. end
  1102. for k,v in pairs(CustomShipments) do
  1103. if not v.noship and table.HasValue(v.allowed, LocalPlayer():Team())
  1104. and (not v.customCheck or (v.customCheck and v.customCheck(LocalPlayer()))) then
  1105. AddEntIcon(v.model, string.format(LANGUAGE.buy_a, "a "..v.name .." shipment", CUR .. tostring(v.price)), "/buyshipment "..v.name)
  1106. shown = shown + 1
  1107. end
  1108. end
  1109. if shown > 0 then
  1110. EntCat:SetContents(EntPanel)
  1111. ItemList:AddItem(EntCat)
  1112. else
  1113. EntPanel:Remove()
  1114. EntCat:Remove()
  1115. end
  1116. end
  1117. if #CustomVehicles > 0 then
  1118. local VehCat = vgui.Create("DCollapsibleCategory")
  1119. VehCat.Paint = function(self,w,h) draw.RoundedBox(4,0,0,w,h,Colors.CategoryBackground) end
  1120. VehCat:SetLabel("Vehicles")
  1121. local VehPanel = vgui.Create("DPanelList")
  1122. VehPanel:SetSize(470, 200)
  1123. VehPanel:SetAutoSize(true)
  1124. VehPanel:EnableHorizontal(true)
  1125. VehPanel:SetPadding(5)
  1126. VehPanel:SetSpacing(5)
  1127. local function AddVehIcon(Model, skin, description, command)
  1128. local button = vgui.Create("DButton")
  1129. button:SetSize(80,80)
  1130. button.Paint = function(self,w,h)
  1131. draw.RoundedBox(4,0,0,w,h,Colors.ButtonBackground)
  1132. return true
  1133. end
  1134. button.PaintOver = function(self,w,h)
  1135. if self.Hovered then
  1136. draw.RoundedBoxEx(4,0,h-20,w,20,Color(0,0,0,200),false,false,true,true)
  1137. draw.SimpleText(description,'DefaultSmall',w/2,h-10,nil,TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER)
  1138. end
  1139. end
  1140. button.DoClick = function() RunCmd(command) end
  1141. button:SetToolTip(description)
  1142. local icon = vgui.Create("SpawnIcon",button)
  1143. icon:InvalidateLayout( true )
  1144. icon:SetModel(Model)
  1145. icon:SetSize(64, 64)
  1146. icon:SetPos(8,8)
  1147. icon:SetMouseInputEnabled(false)
  1148. VehPanel:AddItem(button)
  1149. end
  1150.  
  1151. local shown = 0
  1152. for k,v in pairs(CustomVehicles) do
  1153. if (not v.allowed or table.HasValue(v.allowed, LocalPlayer():Team())) and (not v.customCheck or v.customCheck(LocalPlayer())) then
  1154. local Skin = (list.Get("Vehicles")[v.name] and list.Get("Vehicles")[v.name].KeyValues and list.Get("Vehicles")[v.name].KeyValues.Skin) or "0"
  1155. AddVehIcon(v.model or "models/buggy.mdl", Skin, "Buy a "..v.name.." for "..CUR..v.price, "/buyvehicle "..v.name)
  1156. shown = shown + 1
  1157. end
  1158. end
  1159. if shown > 0 then
  1160. VehCat:SetContents(VehPanel)
  1161. ItemList:AddItem(VehCat)
  1162. else
  1163. VehPanel:Remove()
  1164. VehCat:Remove()
  1165. end
  1166. ItemList:AddItem(VehCat)
  1167. end
  1168. end
  1169.  
  1170. ItemList = vgui.Create('DPanelList',ShopTab)
  1171. ItemList:SetPos(5,5)
  1172. ItemList:SetSize(ShopTab:GetWide()-10,ShopTab:GetTall()-10)
  1173. ItemList:EnableVerticalScrollbar(true)
  1174. ItemList:SetSpacing(5)
  1175.  
  1176. F4Menu.Tabs[ShopButton] = ShopTab
  1177. return ShopButton
  1178. end
  1179. local function AddForumTab()
  1180. local ForumButton = vgui.Create('DButton',F4Menu)
  1181. ForumButton:SetPos(670,F4Menu.Canvas.y-35)
  1182. ForumButton:SetSize(110,35)
  1183. ForumButton.Icon = Materials.ForumButton
  1184. ForumButton.Text = Texts.ForumTabTitle
  1185. ForumButton.DoClick = function(self) F4Menu:OpenTab(self) end
  1186. ForumButton.Paint = function(self,w,h)
  1187. local ry,rh
  1188. if self.Toggled then
  1189. ry,rh = 0,h
  1190. draw.RoundedBoxEx(4,0,ry,w,rh,Color(26,26,26,220),true,true)
  1191. else
  1192. ry,rh = 5,h-5
  1193. draw.RoundedBoxEx(4,0,ry,w,rh,Color(60,60,60,220),true,true)
  1194. end
  1195. surface.SetDrawColor(Color(255,255,255,255))
  1196. surface.SetMaterial(self.Icon)
  1197. surface.DrawTexturedRect(8,ry+rh/2-8,16,16)
  1198. draw.SimpleText(self.Text,Texts.TabTitleFont,32+3,ry+rh/2+3,Color(0,0,0,255),nil,TEXT_ALIGN_CENTER)
  1199. draw.SimpleText(self.Text,Texts.TabTitleFont,32,ry+rh/2,Color(255,255,255,255),nil,TEXT_ALIGN_CENTER)
  1200. return true
  1201. end
  1202.  
  1203. local ForumTab = vgui.Create('DPanel',F4Menu.Canvas)
  1204. ForumTab:SetSize(F4Menu.Canvas:GetSize())
  1205. ForumTab.Paint = function()end
  1206. ForumTab.Refresh = function()end
  1207.  
  1208. local HTML = vgui.Create('HTML',ForumTab)
  1209. HTML:SetPos(0,0)
  1210. HTML:SetSize(ForumTab:GetWide(),ForumTab:GetTall()-35)
  1211. HTML:OpenURL('http://forcegaming.co.uk/rules.html')
  1212.  
  1213.  
  1214. F4Menu.Tabs[ForumButton] = ForumTab
  1215. return ForumButton
  1216. end
  1217.  
  1218. //A small trebuchet20 fix
  1219. surface.CreateFont(Texts.TabTitleFont, {
  1220. font = "Trebuchet MS",
  1221. size = 20,
  1222. weight = 900
  1223. })
  1224. local function ChangeJobVGUI()
  1225. if F4Menu and F4Menu:IsValid() then
  1226. F4Menu:SetVisible(true)
  1227. F4Menu:OpenTab()
  1228. return
  1229. end
  1230. CreateMenu()
  1231. AddJobsTab()
  1232. AddShopTab()
  1233. AddForumTab()
  1234. AddActionsTab()
  1235. end
  1236. usermessage.Hook("ChangeJobVGUI", ChangeJobVGUI)
  1237.  
  1238. local _CreateButton = CreateButton
  1239. local function CreateButton(...)
  1240. local p = _CreateButton(...)
  1241. p:SetTextColor(Color(255,255,255))
  1242. p:SetTextStyleColor(Color(85,85,85,255))
  1243. return p
  1244. end
  1245. local function CreateButtonDialog()
  1246. local dialog = vgui.Create('DPanelList')
  1247. dialog:SetSize(195,25)
  1248. dialog:SetPadding(5)
  1249. dialog:SetSpacing(5)
  1250. dialog:EnableHorizontal(true)
  1251. dialog:SetAutoSize(true)
  1252. dialog:MakePopup()
  1253. dialog:ParentToHUD()
  1254. dialog.PerformLayout = function(self,...)
  1255. DPanelList.PerformLayout(self,...)
  1256. self:Center()
  1257. end
  1258. dialog.Paint = function(self,w,h)
  1259. draw.RoundedBox(4,0,0,w,h,Color(115,115,115,150))
  1260. end
  1261. dialog:AddItem(CreateButton(1,'Close','icon16/delete.png',function()dialog:Remove()end))
  1262. return dialog
  1263. end
  1264. local dialog
  1265. local function KeysMenu(um)
  1266. if dialog and dialog:IsValid() then return end
  1267. local trace = LocalPlayer():GetEyeTraceNoCursor()
  1268. if !trace or !trace.Entity or !trace.Entity:IsValid() then return end
  1269. local Vehicle = um:ReadBool()
  1270. dialog = CreateButtonDialog()
  1271.  
  1272. local DisplayType = Vehicle and "vehicle" or "door"
  1273.  
  1274. local _RunCmd = RunCmd
  1275. local function RunCmd(...)
  1276. _RunCmd(...)
  1277. if ValidPanel(dialog) then
  1278. dialog:Remove()
  1279. end
  1280. end
  1281. local function EditDoorGroup()
  1282. local menu = DermaMenu()
  1283. local groups = menu:AddSubMenu("Door Groups")
  1284. local teams = menu:AddSubMenu("Jobs")
  1285. local add = teams:AddSubMenu("Add")
  1286. local remove = teams:AddSubMenu("Remove")
  1287.  
  1288. menu:AddOption("None", function() RunCmd("/togglegroupownable") end)
  1289. for k,v in pairs(RPExtraTeamDoors) do
  1290. groups:AddOption(k, function() RunCmd("/togglegroupownable",k) end)
  1291. end
  1292.  
  1293. if not trace.Entity.DoorData then return end
  1294.  
  1295. for k,v in pairs(RPExtraTeams) do
  1296. if not trace.Entity.DoorData.TeamOwn or not trace.Entity.DoorData.TeamOwn[k] then
  1297. add:AddOption( v.name, function() RunCmd("/toggleteamownable",k) end )
  1298. else
  1299. remove:AddOption( v.name, function() RunCmd("/toggleteamownable",k) end )
  1300. end
  1301. end
  1302.  
  1303. menu:Open()
  1304. end
  1305. local function EditDoorTitle()
  1306. Derma_StringRequest("Set door title", "Set the title of the "..DisplayType.." you're looking at", "", function(text)
  1307. RunCmd("/title",text)
  1308. end, function() end, "Ok", "Cancel")
  1309. end
  1310.  
  1311. if trace.Entity:OwnedBy(LocalPlayer()) then
  1312. if trace.Entity:IsMasterOwner(LocalPlayer()) then
  1313. dialog:AddItem(CreateButton(1,'Sell '..DisplayType,'icon16/money_add.png',function()RunCmd("/toggleown")end))
  1314. dialog:AddItem(CreateButton(1,'Add owner','icon16/user_add.png',function()
  1315. local menu = DermaMenu()
  1316. menu.found = false
  1317. for k,v in pairs(player.GetAll()) do
  1318. if not trace.Entity:OwnedBy(v) and not trace.Entity:AllowedToOwn(v) then
  1319. menu.found = true
  1320. menu:AddOption(v:Nick(), function() RunCmd("/ao ", v:UserID()) end)
  1321. end
  1322. end
  1323. if not menu.found then
  1324. menu:AddOption("Noone available", function() end)
  1325. end
  1326. menu:Open() end))
  1327. dialog:AddItem(CreateButton(1,'Remove owner','icon16/user_delete.png',function()
  1328. local menu = DermaMenu()
  1329. for k,v in pairs(player.GetAll()) do
  1330. if (trace.Entity:OwnedBy(v) and not trace.Entity:IsMasterOwner(v)) or trace.Entity:AllowedToOwn(v) then
  1331. menu.found = true
  1332. menu:AddOption(v:Nick(), function() RunCmd("/ro",v:UserID()) end)
  1333. end
  1334. end
  1335. if not menu.found then
  1336. menu:AddOption("Noone available", function() end)
  1337. end
  1338. menu:Open() end))
  1339. else
  1340. dialog:AddItem(CreateButton(1,'Unown '..DisplayType,'icon16/money_add.png',function()RunCmd("/toggleown")end))
  1341. end
  1342. dialog:AddItem(CreateButton(1,'Set '..DisplayType..' title','icon16/note_edit.png',EditDoorTitle))
  1343. if LocalPlayer():IsSuperAdmin() and not Vehicle then
  1344. dialog:AddItem(CreateButton(1,'Edit '..DisplayType..' group','icon16/group_edit.png',EditDoorGroup))
  1345. end
  1346. elseif not trace.Entity:OwnedBy(LocalPlayer()) and trace.Entity:IsOwnable() and not trace.Entity:IsOwned() and not trace.Entity.DoorData.NonOwnable then
  1347. if LocalPlayer():IsSuperAdmin() then
  1348. if not trace.Entity.DoorData.GroupOwn then
  1349. dialog:AddItem(CreateButton(1,'Purchase '..DisplayType,'icon16/money_delete.png',function()RunCmd("/toggleown")end))
  1350. end
  1351. dialog:AddItem(CreateButton(1,'Disable ownership','icon16/cancel.png',function()RunCmd("/toggleownable")end))
  1352. dialog:AddItem(CreateButton(1,'Edit '..DisplayType..' group','icon16/group_edit.png',EditDoorGroup))
  1353. elseif not trace.Entity.DoorData.GroupOwn then
  1354. RunCmd("/toggleown")
  1355. else
  1356. dialog:Remove()
  1357. end
  1358. elseif not trace.Entity:OwnedBy(LocalPlayer()) and trace.Entity:AllowedToOwn(LocalPlayer()) then
  1359. if LocalPlayer():IsSuperAdmin() then
  1360. dialog:AddItem(CreateButton(1,'Co-own '..DisplayType,'icon16/money_delete.png',function()RunCmd("/toggleown")end))
  1361. dialog:AddItem(CreateButton(1,'Edit '..DisplayType..' group','icon16/group_edit.png',EditDoorGroup))
  1362. elseif not trace.Entity.DoorData.GroupOwn then
  1363. RunCmd("/toggleown")
  1364. dialog:Remove()
  1365. end
  1366. elseif LocalPlayer():IsSuperAdmin() and trace.Entity.DoorData.NonOwnable then
  1367. dialog:AddItem(CreateButton(1,'Enable ownership','icon16/accept.png',function() RunCmd("/toggleownable") end))
  1368. dialog:AddItem(CreateButton(1,'Set '..DisplayType..' title','icon16/note_edit.png',EditDoorTitle))
  1369. elseif LocalPlayer():IsSuperAdmin() and not trace.Entity:OwnedBy(LocalPlayer()) and trace.Entity:IsOwned() and not trace.Entity:AllowedToOwn(LocalPlayer()) then
  1370. dialog:AddItem(CreateButton(1,'Disable ownership','icon16/cancel.png',function() RunCmd("/toggleownable") end))
  1371. dialog:AddItem(CreateButton(1,'Set '..DisplayType..' title','icon16/note_edit.png',EditDoorTitle))
  1372. dialog:AddItem(CreateButton(1,'Edit '..DisplayType..' group','icon16/group_edit.png',EditDoorGroup))
  1373. else
  1374. dialog:Remove()
  1375. end
  1376. end
  1377. usermessage.Hook("KeysMenu", KeysMenu)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement