Advertisement
wifiboost

Untitled

Mar 13th, 2023
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.93 KB | None | 0 0
  1.  
  2. if IsValid(deceive.GUI) then
  3. deceive.GUI:Remove()
  4. end
  5.  
  6. local cmd = deceive.Config and deceive.Config.UndisguiseCommand or "undisguise"
  7.  
  8. surface.CreateFont("deceive.title", {
  9. font = "Roboto Cn",
  10. size = 21,
  11. weight = 0
  12. })
  13.  
  14. surface.CreateFont("deceive.line", {
  15. font = "Roboto Cn",
  16. size = 16,
  17. weight = 0
  18. })
  19.  
  20. surface.CreateFont("deceive.line2", {
  21. font = "Roboto",
  22. size = 12,
  23. weight = 800
  24. })
  25.  
  26. surface.CreateFont("deceive.close", {
  27. font = "Trebuchet",
  28. size = 14,
  29. weight = 800
  30. })
  31.  
  32. surface.CreateFont("deceive.close2", {
  33. font = "Trebuchet",
  34. size = 10,
  35. weight = 800
  36. })
  37.  
  38. local L = deceive.Translate
  39.  
  40. local PANEL = {}
  41.  
  42. function PANEL:Init()
  43. self:SetSize(400, 368)
  44. self:Center()
  45.  
  46. self.PlayerList = vgui.Create("DListView", self)
  47. self.PlayerList:Dock(LEFT)
  48. self.PlayerList:DockMargin(8, 28 + 8, 8, 8)
  49. self.PlayerList:SetWide(math.ceil(self:GetWide() * 0.58 - 12))
  50.  
  51. self.PlayerList:SetMultiSelect(false)
  52. self.PlayerList:AddColumn(L"disguise_ui_row_name")
  53. self.PlayerList:AddColumn(L"disguise_ui_row_job")
  54.  
  55. self:RefreshList()
  56. function self.PlayerList.OnRowSelected(_, _, line)
  57. local ply = line.Player
  58. if not IsValid(ply) then
  59. self:RefreshList()
  60. return
  61. end
  62.  
  63. self.Player = ply
  64.  
  65. if not self.PlayerModel:IsVisible() then
  66. self.PlayerModel:SetVisible(true)
  67. self.Info:SetVisible(true)
  68. end
  69. self.PlayerModel:SetModel(ply:GetModel())
  70. self.PlayerModel:LayoutEntity()
  71. self.PlayerModel.Entity.GetPlayerColor = function()
  72. return ply:GetPlayerColor()
  73. end
  74.  
  75. local yes, no = L"disguise_ui_yes", L"disguise_ui_no"
  76. local txt = L"disguise_ui_info_player" .. " " .. ply:Nick(true) .. "\n"
  77. txt = txt .. L"disguise_ui_info_job" .. " " .. ply:getDarkRPVar("job", true) .. "\n"
  78. txt = txt .. L"disguise_ui_info_gunlicensed" .. " " .. (ply:getDarkRPVar("HasGunlicense", true) and yes or no) .. "\n"
  79. txt = txt .. L"disguise_ui_info_wanted" .. " " .. (ply:getDarkRPVar("wanted", true) and yes or no) .. "\n"
  80. txt = txt .. L"disguise_ui_info_arrested" .. " " .. (ply:getDarkRPVar("Arrested", true) and yes or no)
  81. self.Info:SetText(txt)
  82. self.Info:SizeToContents()
  83.  
  84. self.Disguise:SetVisible(true)
  85. end
  86.  
  87. self.RightSide = vgui.Create("EditablePanel", self)
  88. self.RightSide:Dock(RIGHT)
  89. self.RightSide:DockMargin(8, 28 + 8, 8, 8)
  90. self.RightSide:SetWide(math.ceil(self:GetWide() * 0.42 - 12))
  91.  
  92. self.PlayerModel = vgui.Create("DModelPanel", self.RightSide)
  93. self.PlayerModel:Dock(TOP)
  94. self.PlayerModel:SetTall(150)
  95. self.PlayerModel:SetVisible(false)
  96. self.PlayerModel:SetFOV(12.5)
  97. function self.PlayerModel:LayoutEntity()
  98. local head = self.Entity:LookupBone("ValveBiped.Bip01_Head1")
  99.  
  100. local headPos
  101. if head then
  102. headPos = self.Entity:GetBonePosition(head)
  103. self.Entity:ManipulateBoneAngles(head, Angle(-10, -5, -20))
  104. else
  105. local mins, maxs = self.Entity:GetModelBounds()
  106. headPos = maxs * 0.85 + Vector(-2.5, 0, 0)
  107. end
  108. self:SetLookAt(headPos + Vector(0, 0, 1.5))
  109.  
  110. local vec = self.Entity:GetAngles():Forward() * 20 + self.Entity:GetAngles():Up() * 62.5 + self.Entity:GetAngles():Right() * 12
  111. self.Entity:SetEyeTarget(vec)
  112. self.Entity:SetPos(Vector(0, -2, 0))
  113. self.Entity:SetAngles(Angle(5, 70, 0))
  114. end
  115.  
  116. self.Info = vgui.Create("DLabel", self.RightSide)
  117. self.Info:Dock(TOP)
  118. self.Info:DockMargin(0, 2, 0, 0)
  119. self.Info:SetVisible(false)
  120. self.Info:SetFont("deceive.line")
  121. self.Info:SetTextColor(Color(230, 230, 255, 192))
  122.  
  123. self.Disguise = vgui.Create("DButton", self.RightSide)
  124. self.Disguise:Dock(BOTTOM)
  125. self.Disguise:SetVisible(false)
  126. self.Disguise:SetText(L"disguise_ui_action")
  127. self.Disguise:SetImage("icon16/briefcase.png")
  128. function self.Disguise.DoClick()
  129. if not IsValid(self.Player) then
  130. notification.AddLegacy(L"disguise_ui_invalid_target", NOTIFY_ERROR, 5)
  131. -- notification.AddLegacy("Your target isn't valid anymore!", NOTIFY_ERROR, 5)
  132. self:RefreshList()
  133. return
  134. end
  135.  
  136. net.Start("deceive.interface")
  137. net.WriteUInt(self.Player:UserID(), 32)
  138. net.SendToServer()
  139. self:Remove()
  140. end
  141.  
  142. self.Info2 = vgui.Create("DLabel", self.RightSide)
  143. self.Info2:Dock(BOTTOM)
  144. self.Info2:DockMargin(0, 0, 0, 2)
  145. -- self.Info2:SetVisible(false)
  146. self.Info2:SetFont("deceive.line2")
  147. self.Info2:SetTextColor(Color(230, 230, 255, 64))
  148. self.Info2:SetWrap(true)
  149. self.Info2:SetAutoStretchVertical(true)
  150. self.Info2:SetText(
  151. string.format(L"disguise_ui_undisguise1", cmd) .. "\n" ..
  152. string.format(L"disguise_ui_undisguise2", cmd)
  153. )
  154. -- self.Info2:SetText("/" .. cmd .. " in chat to remove\nbind '" .. cmd .. "' to a key (through console) to quickly remove")
  155. self.Info2:SizeToContents()
  156.  
  157. self.Close = vgui.Create("DButton", self)
  158. self.Close:SetSize(40, 20)
  159. function self.Close.DoClick()
  160. self:Remove()
  161. end
  162.  
  163. self:Theme()
  164.  
  165. self:MakePopup()
  166. self:SetKeyboardInputEnabled(false)
  167. self:SetMouseInputEnabled(true)
  168.  
  169. self:SetVisible(false)
  170. end
  171.  
  172. function PANEL:PerformLayout()
  173. self.Close:SetPos(self:GetWide() - self.Close:GetWide() - 16, 1)
  174. end
  175.  
  176. function PANEL:RefreshList()
  177. self.PlayerList:Clear()
  178. for _, ply in next, player.GetAll() do
  179. if ply:UserID() ~= LocalPlayer():UserID() then
  180. local line = self.PlayerList:AddLine(ply:Nick(true), team.GetName(ply:Team(true)))
  181. line.Player = ply
  182. end
  183. end
  184. self.Players = player.GetCount()
  185. end
  186.  
  187. local gradient_u = Material("vgui/gradient-u.png")
  188. function PANEL:Theme()
  189. function self.Close:Paint(w, h)
  190. surface.SetDrawColor(255, 64, 64, 64)
  191. surface.DrawRect(0, 0, w, h - 1)
  192. surface.DrawRect(1, h - 1, w - 2, 1)
  193.  
  194. local col = Color(0, 0, 0, 0)
  195. if self:IsHovered() and self.Depressed then
  196. col = Color(0, 0, 0, 64)
  197. elseif self:IsHovered() then
  198. col = Color(255, 255, 255, 3)
  199. end
  200. surface.SetDrawColor(col)
  201. surface.DrawRect(0, 0, w, h)
  202.  
  203. surface.SetFont("deceive.close")
  204. local txt = "✕" -- x, ×, X, ✕, ☓, ✖, ✗, ✘, etc.
  205. local txtW, txtH = surface.GetTextSize(txt)
  206. draw.SimpleTextOutlined(txt, "deceive.close", -2 + w * 0.5 - txtW * 0.5, h * 0.5 - txtH * 0.5, Color(230, 230, 255, 192), TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT, 1, Color(0, 0, 0, 127))
  207.  
  208. return true
  209. end
  210.  
  211. self.PlayerList:SetHeaderHeight(24)
  212. function self.PlayerList:Paint(w, h)
  213. surface.SetDrawColor(47, 47, 65, 127)
  214. surface.DrawRect(1, 1, w - 2, h - 2)
  215.  
  216. surface.SetDrawColor(17, 17, 25, 192)
  217. surface.DrawRect(0, 1, 1, h - 2) -- left
  218. surface.DrawRect(w - 1, 1, 1, h - 2) -- right
  219. surface.DrawRect(1, 0, w - 2, 1) -- top
  220. surface.DrawRect(1, h - 1, w - 2, 1) -- bottom
  221. end
  222. function self.PlayerList.VBar:Paint(w, h)
  223. surface.SetDrawColor(27, 27, 35, 127)
  224. surface.DrawRect(0, 0, w, h)
  225. end
  226. function self.PlayerList.VBar.btnGrip:Paint(w, h)
  227. surface.SetDrawColor(45, 45, 64, 192)
  228. surface.DrawRect(1, 1, w - 2, h - 2)
  229.  
  230. if self.Depressed then
  231. surface.SetDrawColor(0, 0, 0, 64)
  232. surface.DrawRect(1, 1, w - 2, h - 2)
  233. elseif self:IsHovered() then
  234. surface.SetDrawColor(255, 255, 255, 2)
  235. surface.DrawRect(1, 1, w - 2, h - 2)
  236. end
  237.  
  238. surface.SetDrawColor(17, 17, 25, 225)
  239. surface.DrawRect(0, 1, 1, h - 2) -- left
  240. surface.DrawRect(w - 1, 1, 1, h - 2) -- right
  241. surface.DrawRect(1, 0, w - 2, 1) -- top
  242. surface.DrawRect(1, h - 1, w - 2, 1) -- bottom
  243. end
  244. for k, v in next, {"Up", "Down"} do
  245. self.PlayerList.VBar["btn" .. v].Paint = function(self, w, h)
  246. surface.SetDrawColor(45, 45, 64, 192)
  247. surface.DrawRect(1, 1, w - 2, h - 2)
  248.  
  249. if self.Depressed then
  250. surface.SetDrawColor(0, 0, 0, 64)
  251. surface.DrawRect(1, 1, w - 2, h - 2)
  252. elseif self:IsHovered() then
  253. surface.SetDrawColor(255, 255, 255, 2)
  254. surface.DrawRect(1, 1, w - 2, h - 2)
  255. end
  256.  
  257. surface.SetFont("deceive.close2")
  258. local txt = k == 1 and "▲" or "▼" -- x, ×, X, ✕, ☓, ✖, ✗, ✘, etc.
  259. local txtW, txtH = surface.GetTextSize(txt)
  260. draw.SimpleTextOutlined(txt, "deceive.close2", -1 + w * 0.5 - txtW * 0.5, h * 0.5 - txtH * 0.5, Color(230, 230, 255, 192), TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT, 1, Color(0, 0, 0, 127))
  261.  
  262. surface.SetDrawColor(17, 17, 25, 225)
  263. surface.DrawRect(0, 1, 1, h - 2) -- left
  264. surface.DrawRect(w - 1, 1, 1, h - 2) -- right
  265. surface.DrawRect(1, 0, w - 2, 1) -- top
  266. surface.DrawRect(1, h - 1, w - 2, 1) -- bottom
  267. end
  268. end
  269.  
  270. for k, column in next, self.PlayerList.Columns do
  271. function column.Header:Paint(w, h)
  272. surface.SetDrawColor(27, 27, 47, 192)
  273. surface.DrawRect(0, 0, w, h)
  274.  
  275. surface.SetMaterial(gradient_u)
  276. surface.SetDrawColor(47, 47, 65, 64)
  277. surface.DrawTexturedRect(1, 1, w - 2, h - 2)
  278.  
  279. if self.Depressed then
  280. surface.SetDrawColor(0, 0, 0, 64)
  281. surface.DrawRect(1, 1, w - 2, h - 2)
  282. elseif self:IsHovered() then
  283. surface.SetDrawColor(255, 255, 255, 2)
  284. surface.DrawRect(1, 1, w - 2, h - 2)
  285. end
  286.  
  287. surface.SetDrawColor(17, 17, 25, 92)
  288. surface.DrawOutlinedRect(0, 0, w, h)
  289.  
  290. surface.SetFont("deceive.line")
  291. local txt = self:GetText()
  292. local txtW, txtH = surface.GetTextSize(txt)
  293. surface.SetTextPos(w * 0.5 - txtW * 0.5, h * 0.5 - txtH * 0.5)
  294. surface.SetTextColor(240, 240, 255, 192)
  295. surface.DrawText(txt)
  296.  
  297. return true
  298. end
  299. end
  300.  
  301. for k, line in next, self.PlayerList.Lines do
  302. function line:Paint(w, h)
  303. local ply = line.Player
  304. if not IsValid(ply) then self:Remove() end
  305.  
  306. -- local col = Color(120, 120, 180, 0)
  307. local col = table.Copy(ply.getJobTable and ply:getJobTable(true).color or team.GetColor(ply:Team(true)))
  308. col.a = 10
  309. if self:IsHovered() and self:IsSelected() or self:IsSelected() then
  310. col.a = 50
  311. elseif self:IsHovered() or self:IsSelected() then
  312. col.a = 25
  313. end
  314. surface.SetDrawColor(col)
  315. surface.DrawRect(0, 0, w - 1, h)
  316. end
  317.  
  318. for _, column in next, line.Columns do
  319. column:SetFont("deceive.line")
  320. function column:UpdateColours()
  321. if self:GetParent():IsLineSelected() then
  322. return self:SetTextStyleColor(Color(230, 230, 255, 255))
  323. end
  324.  
  325. return self:SetTextStyleColor(Color(192, 192, 225, 127))
  326. end
  327. end
  328. end
  329.  
  330. function self.PlayerModel:Paint(w, h)
  331. surface.SetDrawColor(27, 27, 35, 127)
  332. surface.DrawRect(0, 0, w, h)
  333.  
  334. DModelPanel.Paint(self, w, h)
  335.  
  336. DisableClipping(true)
  337.  
  338. surface.SetDrawColor(17, 17, 25, 192)
  339. surface.DrawRect(-1, 0, 1, h) -- left
  340. surface.DrawRect(w, 0, 1, h) -- right
  341. surface.DrawRect(0, -1, w, 1) -- top
  342. surface.DrawRect(0, h, w, 1) -- bottom
  343.  
  344. DisableClipping(false)
  345. end
  346.  
  347. function self.Disguise:Paint(w, h)
  348. surface.SetDrawColor(27, 27, 47, 192)
  349. surface.DrawRect(0, 0, w, h)
  350.  
  351. surface.SetMaterial(gradient_u)
  352. surface.SetDrawColor(47, 47, 65, 64)
  353. surface.DrawTexturedRect(1, 1, w - 2, h - 2)
  354.  
  355. if self.Depressed then
  356. surface.SetDrawColor(0, 0, 0, 64)
  357. surface.DrawRect(1, 1, w - 2, h - 2)
  358. elseif self:IsHovered() then
  359. surface.SetDrawColor(255, 255, 255, 2)
  360. surface.DrawRect(1, 1, w - 2, h - 2)
  361. end
  362.  
  363. surface.SetDrawColor(17, 17, 25, 92)
  364. surface.DrawOutlinedRect(0, 0, w, h)
  365.  
  366. surface.SetFont("deceive.line")
  367. local txt = self:GetText()
  368. local txtW, txtH = surface.GetTextSize(txt)
  369. surface.SetTextPos(w * 0.5 - txtW * 0.5, h * 0.5 - txtH * 0.5)
  370. surface.SetTextColor(240, 240, 255, 192)
  371. surface.DrawText(txt)
  372.  
  373. return true
  374. end
  375. end
  376.  
  377. function PANEL:Paint(w, h)
  378. surface.SetDrawColor(37, 37, 45, 235)
  379. surface.DrawRect(1, 1, w - 2, h - 2)
  380.  
  381. surface.SetDrawColor(17, 17, 25, 92)
  382. surface.DrawRect(1, 1, w - 2, 28)
  383.  
  384. surface.SetDrawColor(17, 17, 25, 225)
  385. surface.DrawRect(0, 1, 1, h - 2) -- left
  386. surface.DrawRect(w - 1, 1, 1, h - 2) -- right
  387. surface.DrawRect(1, 0, w - 2, 1) -- top
  388. surface.DrawRect(1, h - 1, w - 2, 1) -- bottom
  389.  
  390. surface.SetFont("deceive.title")
  391. local txt = L"disguise_ui_title"
  392. local txtW, txtH = surface.GetTextSize(txt)
  393. surface.SetTextPos(w * 0.5 - txtW * 0.5, 1 + 28 * 0.5 - txtH * 0.5)
  394. surface.SetTextColor(240, 240, 255, 192)
  395. surface.DrawText(txt)
  396. end
  397.  
  398. function PANEL:Show()
  399. self:SetVisible(true)
  400. end
  401.  
  402. function PANEL:Hide()
  403. self:SetVisible(false)
  404. end
  405.  
  406. function PANEL:Think()
  407. if not IsValid(self.Entity) then self:Remove() return end
  408.  
  409. if LocalPlayer():GetPos():Distance(self.Entity:GetPos()) > 95 then
  410. self:Remove()
  411. return
  412. end
  413.  
  414. if self.Players ~= player.GetCount() then
  415. self:RefreshList()
  416. self:Theme()
  417. end
  418. end
  419.  
  420. vgui.Register("deceive.interface", PANEL, "EditablePanel")
  421.  
  422. net.Receive("deceive.interface", function()
  423. if not IsValid(deceive.GUI) then
  424. deceive.GUI = vgui.Create("deceive.interface")
  425. end
  426.  
  427. local entIndex = net.ReadUInt(32)
  428. local ent = Entity(entIndex)
  429. if not IsValid(ent) then return end
  430.  
  431. deceive.GUI.Entity = ent
  432. deceive.GUI:Show()
  433. end)
  434.  
  435. net.Receive("deceive.notify", function()
  436. local str = net.ReadString()
  437. local typ = net.ReadUInt(8)
  438. local time = net.ReadUInt(8)
  439. local extra = net.ReadTable()
  440. local _str = string.format(L(str), unpack(extra))
  441. notification.AddLegacy(_str, typ, time)
  442. print(_str)
  443. end)
  444.  
  445. concommand.Add(cmd, function()
  446. -- lazy but should do the trick nicely
  447. RunConsoleCommand("say", "/" .. cmd)
  448. end)
  449.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement