Guest User

Untitled

a guest
May 17th, 2012
38
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. include("ass_shared.lua")
  2.  
  3. ASS_Initialized = false
  4.  
  5. local PLAYER = FindMetaTable("Player")
  6. function PLAYER:UniqueID() return self:GetNetworkedString("ASS_UniqueID") end
  7. PLAYER = nil
  8.  
  9. function ASS_BanPlayer( INFO )
  10. if (!ValidEntity(INFO.Player)) then
  11. return true
  12. end
  13.  
  14. if (#INFO.Reason > 0) then
  15. RunConsoleCommand("ASS_BanPlayer", INFO.Player:UniqueID(), INFO.Time, INFO.Reason)
  16. else
  17. RunConsoleCommand("ASS_BanPlayer", INFO.Player:UniqueID(), INFO.Time)
  18. end
  19.  
  20. return true
  21. end
  22.  
  23. function ASS_KickPlayer( INFO )
  24. if (!ValidEntity(INFO.Player)) then
  25. return true
  26. end
  27.  
  28. if (#INFO.Reason > 0) then
  29. RunConsoleCommand("ASS_KickPlayer", INFO.Player:UniqueID(), INFO.Reason)
  30. else
  31. RunConsoleCommand("ASS_KickPlayer", INFO.Player:UniqueID() )
  32. end
  33.  
  34. return true
  35. end
  36.  
  37. function ASS_SetAccess( PLAYER, LEVEL, TIME )
  38.  
  39. if (!ValidEntity(PLAYER)) then
  40. return true
  41. end
  42.  
  43. if (TIME) then
  44. RunConsoleCommand("ASS_PromotePlayer", PLAYER:UniqueID(), LEVEL, TIME)
  45. else
  46. RunConsoleCommand("ASS_PromotePlayer", PLAYER:UniqueID(), LEVEL)
  47. end
  48.  
  49. end
  50.  
  51. function ASS_CustomReason(INFO)
  52.  
  53. Derma_StringRequest( "Custom Reason...",
  54. "Why do you want to " .. INFO.Type .. " " .. INFO.Player:Nick() .. "?",
  55. "",
  56. function( strTextOut )
  57. table.insert(ASS_Config["reasons"], { name = strTextOut, reason = strTextOut } )
  58. ASS_WriteConfig()
  59.  
  60. INFO.Reason = strTextOut
  61. INFO.Function(INFO)
  62. end
  63. )
  64. end
  65.  
  66. function ASS_KickBanReasonMenu( MENU, INFO )
  67.  
  68. INFO = INFO or {}
  69.  
  70. for k, v in pairs(ASS_Config["reasons"]) do
  71. MENU:AddOption( (v.name or ("Unnamed #" .. k)),
  72. function()
  73. INFO.Reason = v.reason or ""
  74. return INFO.Function(INFO)
  75. end
  76. )
  77. end
  78. MENU:AddSpacer()
  79. MENU:AddOption( "Custom...",
  80. function()
  81. ASS_CustomReason(INFO)
  82. end
  83. )
  84.  
  85. end
  86.  
  87. function ASS_BanTimeMenu( MENU, PLAYER )
  88.  
  89. for k, v in pairs(ASS_Config["ban_times"]) do
  90.  
  91. local txt = v.name or ("Unnamed #" .. k)
  92.  
  93. MENU:AddSubMenu( txt, nil, function(NEWMENU) ASS_KickBanReasonMenu( NEWMENU, { ["Type"] = "ban", ["Function"] = ASS_BanPlayer, ["Player"] = PLAYER, ["Time"] = v.time } ) end )
  94.  
  95. end
  96.  
  97. end
  98.  
  99. function ASS_KickReasonMenu( MENUITEM, PLAYER, INFO )
  100.  
  101. INFO = {}
  102. INFO.Function = ASS_KickPlayer
  103. INFO.Type = "kick"
  104. INFO.Player = PLAYER
  105.  
  106. ASS_KickBanReasonMenu(MENUITEM, INFO)
  107.  
  108. end
  109.  
  110. function ASS_TempAdminMenu( MENU, PLAYER )
  111.  
  112. for k, v in pairs(ASS_Config["temp_admin_times"]) do
  113. MENU:AddOption(v.name, function() ASS_SetAccess(PLAYER, ASS_LVL_TEMPADMIN, v.time) end )
  114. end
  115.  
  116. end
  117.  
  118. function ASS_AccessMenu( SUBMENU, PLAYER )
  119.  
  120. local Items = {}
  121. Items[ASS_LVL_SUPER_ADMIN] = SUBMENU:AddOption( "Super Admin", function() ASS_SetAccess(PLAYER, ASS_LVL_SUPER_ADMIN) end )
  122. Items[ASS_LVL_ADMIN] = SUBMENU:AddOption( "Admin", function() ASS_SetAccess(PLAYER, ASS_LVL_ADMIN) end )
  123. Items[ASS_LVL_TEMPADMIN] = SUBMENU:AddSubMenu( "Temp Admin" , nil, function(NEWMENU) ASS_TempAdminMenu( NEWMENU, PLAYER ) end )
  124. Items[ASS_LVL_DONATOR] = SUBMENU:AddOption( "Donator", function() ASS_SetAccess(PLAYER, ASS_LVL_DONATOR) end )
  125. Items[ASS_LVL_RESPECTED] = SUBMENU:AddOption( "Respected", function() ASS_SetAccess(PLAYER, ASS_LVL_RESPECTED) end )
  126. Items[ASS_LVL_GUEST] = SUBMENU:AddOption( "Guest", function() ASS_SetAccess(PLAYER, ASS_LVL_GUEST) end )
  127.  
  128. if (Items[ PLAYER:GetLevel() ]) then
  129. Items[PLAYER:GetLevel()]:SetImage("gui/silkicons/check_on_s")
  130. end
  131.  
  132. end
  133.  
  134. function ASS_TableContains( TAB, VAR )
  135.  
  136. if (!TAB) then
  137.  
  138. return false
  139.  
  140. end
  141.  
  142. for k,v in pairs(TAB) do
  143.  
  144. if (v == VAR) then
  145.  
  146. return true
  147.  
  148. end
  149.  
  150. end
  151.  
  152. return false
  153.  
  154. end
  155.  
  156. function ASS_FixMenu( MENU )
  157.  
  158. // Call the callback when we need to build the menu
  159. // If we're creating the menu now, also register our
  160. // hacked functions with it, so this hack propagates
  161. // virus like among any DMenus spawned from this
  162. // parent DMenu.. muhaha
  163. function DMenuOption_OnCursorEntered(self)
  164.  
  165. local m = self.SubMenu
  166. if (self.BuildFunction) then
  167. m = DermaMenu( self )
  168. ASS_FixMenu(m)
  169. m:SetVisible( false )
  170. m:SetParent( self:GetParent() )
  171. PCallError( self.BuildFunction, m)
  172. end
  173.  
  174. self.ParentMenu:OpenSubMenu( self, m )
  175.  
  176. end
  177.  
  178. // Menu item images!
  179. function DMenuOption_SetImage(self, img)
  180.  
  181. self.Image = ASS_Icon(img)
  182.  
  183. end
  184.  
  185. // Change the released hook so that if the click function
  186. // returns a non-nil or non-false value then the menus
  187. // get closed (this way menus can stay opened and be clicked
  188. // several time).
  189. function DMenuOption_OnMouseReleased( self, mousecode )
  190. DButton.OnMouseReleased( self, mousecode )
  191. if ( self.m_MenuClicking ) then
  192. self.m_MenuClicking = false
  193. if (!self.ClickReturn) then
  194. CloseDermaMenus()
  195. end
  196. end
  197. end
  198.  
  199. // Make sure we draw the image, should be done in the skin
  200. // but this is a total hack, so meh.
  201. function DMenuOption_Paint(self)
  202. derma.SkinHook( "Paint", "MenuOption", self )
  203. if (self.Image) then
  204. surface.SetTexture( self.Image )
  205. surface.SetDrawColor( 255, 255, 255, 255 )
  206. surface.DrawTexturedRect( 2, (self:GetTall() - 16) * 0.5, 16, 16)
  207. end
  208. return false
  209. end
  210.  
  211. // Make DMenuOptions implement our new functions above.
  212. // Returns the new DMenuOption created.
  213. local function DMenu_AddOption( self, strText, funcFunction )
  214. local pnl = vgui.Create( "DMenuOption", self )
  215. pnl.OnCursorEntered = DMenuOption_OnCursorEntered
  216. pnl.OnMouseReleased = DMenuOption_OnMouseReleased
  217. pnl.Paint = DMenuOption_Paint
  218. pnl.SetImage = DMenuOption_SetImage
  219. pnl:SetText( strText )
  220. if ( funcFunction ) then
  221. pnl.DoClick = function(self)
  222. self.ClickReturn = funcFunction(pnl)
  223. end
  224. end
  225.  
  226. self:AddPanel( pnl )
  227. return pnl
  228. end
  229.  
  230. // Make DMenuOptions implement our new functions above.
  231. // If we're creating the menu now, also register our
  232. // hacked functions with it, so this hack propagates
  233. // virus like among any DMenus spawned from this
  234. // parent DMenu.. muhaha
  235. // Returns the new DMenu (if it exists), and the DMenuOption
  236. // created.
  237. local function DMenu_AddSubMenu( self, strText, funcFunction, openFunction )
  238. local SubMenu = nil
  239. if (!openFunction) then
  240. SubMenu = DermaMenu( self )
  241. ASS_FixMenu(SubMenu)
  242. SubMenu:SetVisible( false )
  243. SubMenu:SetParent( self )
  244. end
  245.  
  246. local pnl = vgui.Create( "DMenuOption", self )
  247. pnl.OnCursorEntered = DMenuOption_OnCursorEntered
  248. pnl.OnMouseReleased = DMenuOption_OnMouseReleased
  249. pnl.Paint = DMenuOption_Paint
  250. pnl.SetImage = DMenuOption_SetImage
  251. pnl.BuildFunction = openFunction
  252. pnl:SetSubMenu( SubMenu )
  253. pnl:SetText( strText )
  254. if ( funcFunction ) then
  255. pnl.DoClick = function() pnl.ClickReturn = funcFunction(pnl) end
  256. else
  257. pnl.DoClick = function() pnl.ClickReturn = true end
  258. end
  259.  
  260. self:AddPanel( pnl )
  261. if (SubMenu) then
  262. return SubMenu, pnl
  263. else
  264. return pnl
  265. end
  266. end
  267.  
  268. // Register our new hacked function. muhahah
  269. MENU.AddOption = DMenu_AddOption
  270. MENU.AddSubMenu = DMenu_AddSubMenu
  271. end
  272.  
  273.  
  274. function ASS_PlayerMenu( SUBMENU, OPTIONS, FUNCTION, ... )
  275.  
  276. if (type(SUBMENU) != "Panel") then Msg("ASS_PlayerMenu: SUBMENU isn't a menu!\n") return end
  277.  
  278. local others = player.GetAll()
  279.  
  280. local includeSubMenus = ASS_TableContains(OPTIONS, "HasSubMenu")
  281. local includeSelf = ASS_TableContains(OPTIONS, "IncludeLocalPlayer")
  282. local includeAll = ASS_TableContains(OPTIONS, "IncludeAll")
  283. local includeAllSO = ASS_TableContains(OPTIONS, "IncludeAllSO")
  284.  
  285. local NumOptions = 0
  286.  
  287. if (includeAll || includeAllSO) then
  288.  
  289. /* I love anonymous functions, good luck understanding what this does! */
  290.  
  291. if (LocalPlayer():HasLevel(ASS_LVL_SERVER_OWNER) || includeAllSO) then
  292. SUBMENU:AddSubMenu( "All", nil,
  293. function(ALLMENU)
  294. if (includeSubMenus) then
  295.  
  296. ALLMENU:AddSubMenu( "Players", nil,
  297. function(NEWMENU)
  298. local List = {}
  299. for _, PL in pairs(player.GetAll()) do
  300. if (PL != LocalPlayer() || includeSelf) then
  301. table.insert(List, PL)
  302. end
  303. end
  304. PCallError( FUNCTION, NEWMENU, List, unpack(arg))
  305. end )
  306.  
  307. ALLMENU:AddSubMenu( "Non-Admins", nil,
  308. function(NEWMENU)
  309. local List = {}
  310. for _, PL in pairs(player.GetAll()) do
  311. if (!PL:IsAdmin() && (PL != LocalPlayer() || includeSelf)) then
  312. table.insert(List, PL)
  313. end
  314. end
  315. PCallError( FUNCTION, NEWMENU, List, unpack(arg))
  316. end )
  317.  
  318. ALLMENU:AddSubMenu( "Admins", nil,
  319. function(NEWMENU)
  320. local List = {}
  321. for _, PL in pairs(player.GetAll()) do
  322. if (PL:IsAdmin() && (PL != LocalPlayer() || includeSelf)) then
  323. table.insert(List, PL)
  324. end
  325. end
  326. PCallError( FUNCTION, NEWMENU, List, unpack(arg))
  327. end )
  328. else
  329.  
  330. ALLMENU:AddOption( "Players",
  331. function()
  332. local res = nil
  333. for _, PL in pairs(player.GetAll()) do
  334. if (PL != LocalPlayer() || includeSelf) then
  335. local err,res2 = PCallError( FUNCTION, PL, unpack(arg))
  336. res = res || res2
  337. end
  338. end
  339. return res
  340. end )
  341. ALLMENU:AddOption( "Non-Admins",
  342. function()
  343. local res = nil
  344. for _, PL in pairs(player.GetAll()) do
  345. if (!PL:IsAdmin() && (PL != LocalPlayer() || includeSelf)) then
  346. local err,res2 = PCallError( FUNCTION, PL, unpack(arg))
  347. res = res || res2
  348. end
  349. end
  350. return res
  351. end )
  352. ALLMENU:AddOption( "Admins",
  353. function()
  354. local res = nil
  355. for _, PL in pairs(player.GetAll()) do
  356. if (PL:IsAdmin() && (PL != LocalPlayer() || includeSelf)) then
  357. local err,res2 = PCallError( FUNCTION, PL, unpack(arg))
  358. res = res || res2
  359. end
  360. end
  361. return res
  362. end )
  363.  
  364. end
  365. end )
  366. else
  367.  
  368. if (includeSubMenus) then
  369.  
  370. SUBMENU:AddSubMenu( "All Non-Admins", nil,
  371. function(NEWMENU)
  372. local List = {}
  373. for _, PL in pairs(player.GetAll()) do
  374. if (!PL:IsAdmin()) then
  375. table.insert(List, PL)
  376. end
  377. end
  378. PCallError( FUNCTION, NEWMENU, List, unpack(arg))
  379. end )
  380.  
  381. else
  382.  
  383. SUBMENU:AddOption( "All Non-Admins",
  384. function()
  385. local res = nil
  386. for _, PL in pairs(player.GetAll()) do
  387. if (!PL:IsAdmin()) then
  388. local err, res2 = PCallError( FUNCTION, PL, unpack(arg))
  389. res = res or res2
  390. end
  391. end
  392. return res
  393. end )
  394.  
  395. end
  396.  
  397. end
  398.  
  399. NumOptions = NumOptions + 1
  400.  
  401. if (includeSelf) then
  402. SUBMENU:AddSpacer()
  403. end
  404.  
  405. end
  406.  
  407. if (includeSelf) then
  408. if (includeSubMenus) then
  409. SUBMENU:AddSubMenu( LocalPlayer():Nick(), nil, function(NEW_SUBMENU) PCallError( FUNCTION, NEW_SUBMENU, LocalPlayer(), unpack(arg) ) end )
  410. else
  411. SUBMENU:AddOption( LocalPlayer():Nick(), function() local err,res = PCallError( FUNCTION, LocalPlayer(), unpack(arg)) return res end )
  412. end
  413. NumOptions = NumOptions + 1
  414. end
  415.  
  416. for idx,ply in pairs(others) do
  417.  
  418. if (ply != LocalPlayer()) then
  419. if (NumOptions == 1 && (includeSelf || includeAll || includeAllSO)) then
  420. SUBMENU:AddSpacer()
  421. end
  422. if (includeSubMenus) then
  423. SUBMENU:AddSubMenu( ply:Nick(), nil, function(NEW_SUBMENU) PCallError( FUNCTION, NEW_SUBMENU, ply, unpack(arg) ) end )
  424. else
  425. SUBMENU:AddOption( ply:Nick(), function() local err,res = PCallError( FUNCTION, ply, unpack(arg)) return res end )
  426. end
  427. NumOptions = NumOptions + 1
  428. end
  429.  
  430. end
  431.  
  432. if (NumOptions == 0) then
  433. SUBMENU:AddOption( "(none)", function() end )
  434. end
  435.  
  436. end
  437.  
  438. function ASS_Plugins( SUBMENU )
  439.  
  440. ASS_RunPluginFunction("AddMenu", nil, SUBMENU )
  441.  
  442. if (#SUBMENU:GetItems() == 0) then
  443. SUBMENU:AddOption("(none)", function() end)
  444. end
  445.  
  446. end
  447.  
  448. function ASS_Gamemode( SUBMENU )
  449.  
  450. local function CheckGamemode(PLUGIN)
  451.  
  452. return PLUGIN.Gamemodes != nil &&
  453. #PLUGIN.Gamemodes > 0 &&
  454. ASS_PluginCheckGamemode(PLUGIN.Gamemodes)
  455.  
  456. end
  457.  
  458. ASS_RunPluginFunctionFiltered("AddGamemodeMenu", CheckGamemode, nil, SUBMENU )
  459.  
  460. if (#SUBMENU:GetItems() == 0) then
  461. SUBMENU:AddOption("(none)", function() end)
  462. end
  463.  
  464. end
  465.  
  466. function ASS_Rcon(TEXT, TIME)
  467.  
  468. RunConsoleCommand("ASS_RconBegin" )
  469.  
  470. local i = 1
  471. while (i <= #TEXT) do
  472.  
  473. local args = {}
  474. for j=i, i+6 do
  475. if (j > #TEXT) then
  476. break
  477. end
  478. args[j-i+1] = string.byte(TEXT, j)
  479. end
  480.  
  481.  
  482. RunConsoleCommand("ASS_Rcon", unpack(args) )
  483.  
  484. i = i + 7
  485. end
  486.  
  487. RunConsoleCommand("ASS_RconEnd", (TIME or 0) )
  488.  
  489. end
  490.  
  491. function ASS_RconEntry(MENUITEM)
  492.  
  493. Derma_StringRequest( "Remote Command...",
  494. "What command do you want to execute?",
  495. "",
  496. function( TEXT )
  497.  
  498. local found = false
  499. for k,v in pairs(ASS_Config["rcon"]) do
  500. if (string.lower(v.cmd) == string.lower(TEXT)) then
  501. found = true
  502. break
  503. end
  504. end
  505.  
  506. if (!found) then
  507. table.insert(ASS_Config["rcon"], { cmd=TEXT } )
  508. ASS_WriteConfig()
  509. end
  510.  
  511. ASS_Rcon(TEXT)
  512.  
  513. end
  514. )
  515.  
  516. end
  517.  
  518. function ASS_RconMenu( MENU )
  519.  
  520. MENU:AddOption( "Custom...", ASS_RconEntry )
  521. MENU:AddSpacer()
  522. for k,v in pairs(ASS_Config["rcon"]) do
  523. MENU:AddOption( v.cmd, function(MENUITEM) ASS_Rcon(v.cmd) end )
  524. end
  525.  
  526. end
  527.  
  528.  
  529. function ASS_ShowUnbanList()
  530.  
  531. PromptForChoice( "Unban a player...", ASS_BannedPlayers,
  532. function (DLG, ITEM)
  533.  
  534. RunConsoleCommand("ASS_UnBanPlayer", ITEM.ID)
  535. DLG:RemoveItem(DLG.Selection)
  536.  
  537. end
  538. )
  539.  
  540. ASS_BannedPlayers = nil
  541.  
  542. end
  543.  
  544. function ASS_UnbanMenu( MENUITEM )
  545.  
  546. if (ASS_BannedPlayers) then return end
  547.  
  548. ASS_BannedPlayers = {}
  549. RunConsoleCommand("ASS_UnbanList")
  550.  
  551. end
  552.  
  553. local IconsLoaded = {}
  554. function ASS_Icon( img )
  555. if (IconsLoaded[img]) then
  556. return IconsLoaded[img]
  557. end
  558. IconsLoaded[img] = surface.GetTextureID(img)
  559. return IconsLoaded[img]
  560. end
  561.  
  562. function ASS_ShowMenu()
  563.  
  564. local MENU = DermaMenu()
  565. ASS_FixMenu(MENU)
  566.  
  567. if (!LocalPlayer():IsTempAdmin()) then
  568.  
  569. ASS_RunPluginFunction("AddNonAdminMenu", nil, MENU )
  570. if (#MENU.Panels == 0) then
  571. return
  572. end
  573.  
  574. else
  575.  
  576. local GamemodeImage = "gui/silkicons/sport_soccer"
  577. if (GAMEMODE.ASS_MenuIcon) then
  578. GamemodeImage = GAMEMODE.ASS_MenuIcon
  579. end
  580.  
  581. MENU:AddSubMenu("Set Access", nil, function(NEWMENU) ASS_PlayerMenu(NEWMENU, { "HasSubMenu" }, ASS_AccessMenu ) end ):SetImage( "gui/silkicons/key" )
  582. MENU:AddSubMenu("Kick", nil, function(NEWMENU) ASS_PlayerMenu(NEWMENU, { "HasSubMenu" }, ASS_KickReasonMenu ) end ):SetImage( "gui/silkicons/error" )
  583. MENU:AddSubMenu("Ban", nil, function(NEWMENU) ASS_PlayerMenu(NEWMENU, { "HasSubMenu" }, ASS_BanTimeMenu ) end ):SetImage( "gui/silkicons/exclamation" )
  584. MENU:AddSpacer()
  585. MENU:AddSubMenu("Rcon", nil, ASS_RconMenu):SetImage( "gui/silkicons/application_xp_terminal" )
  586. MENU:AddSpacer()
  587. MENU:AddSubMenu("Plugins", nil, ASS_Plugins ):SetImage( "gui/silkicons/wrench" )
  588. MENU:AddSubMenu( GAMEMODE.Name, nil, ASS_Gamemode ):SetImage(GamemodeImage)
  589.  
  590. ASS_RunPluginFunction("AddMainMenu", nil, MENU )
  591.  
  592. end
  593.  
  594. MENU:Open( 100, 100 )
  595. ASS_MenuShowing = true
  596. timer.Simple( 0, gui.SetMousePos, 110, 110 )
  597.  
  598. ASS_Debug( "menu opened\n")
  599.  
  600. end
  601.  
  602. function ASS_HideMenu()
  603.  
  604. CloseDermaMenus()
  605. ASS_Debug( "menu hiding\n")
  606. ASS_MenuShowing = false
  607.  
  608. end
  609.  
  610. local CountDownPanel = nil
  611. local NoticePanel = nil
  612.  
  613. function ASS_Countdown( NAME, TEXT, DURATION )
  614.  
  615. if (!CountDownPanel) then
  616. CountDownPanel = vgui.Create("DCountDownList")
  617. if (NoticePanel) then
  618. NoticePanel.CountDownPanel = CountDownPanel
  619. end
  620. end
  621.  
  622. CountDownPanel:AddCountdown(NAME, TEXT, DURATION)
  623.  
  624. if (NoticePanel) then
  625. NoticePanel:InvalidateLayout()
  626. end
  627. end
  628.  
  629. function ASS_RemoveCountdown( NAME )
  630.  
  631. if (!CountDownPanel) then
  632. return
  633. end
  634.  
  635. CountDownPanel:RemoveCountdown( NAME )
  636.  
  637. if (NoticePanel) then
  638. NoticePanel:InvalidateLayout()
  639. end
  640. end
  641.  
  642. function ASS_BeginProgress( NAME, TEXT, MAXIMUM )
  643.  
  644. if (MAXIMUM == 0) then
  645. return
  646. end
  647.  
  648. if (!CountDownPanel) then
  649. CountDownPanel = vgui.Create("DCountDownList")
  650. if (NoticePanel) then
  651. NoticePanel.CountDownPanel = CountDownPanel
  652. end
  653. end
  654.  
  655. CountDownPanel:AddProgress(NAME, TEXT, MAXIMUM)
  656.  
  657. if (NoticePanel) then
  658. NoticePanel:InvalidateLayout()
  659. end
  660. end
  661.  
  662. function ASS_IncProgress( NAME, INC )
  663.  
  664. if (!CountDownPanel) then return end
  665.  
  666. CountDownPanel:IncProgress(NAME, INC || 1)
  667.  
  668. end
  669.  
  670. function ASS_EndProgress( NAME )
  671.  
  672. if (!CountDownPanel) then
  673. return
  674. end
  675.  
  676. CountDownPanel:RemoveCountdown( NAME )
  677.  
  678. if (NoticePanel) then
  679. NoticePanel:InvalidateLayout()
  680. end
  681.  
  682. end
  683.  
  684. function ASS_ShouldShowNoticeBar()
  685.  
  686. if (GAMEMODE.ASS_HideNoticeBar) then
  687. return false
  688. end
  689.  
  690. return (tonumber(ASS_Config["show_notice_bar"]) or 1) == 1
  691.  
  692. end
  693.  
  694. function ASS_Notice( NAME, TEXT, DURATION )
  695.  
  696. //if (!NoticePanel) then
  697. //NoticePanel = vgui.Create("DNoticePanel")
  698. //NoticePanel.CountDownPanel = CountDownPanel
  699. //NoticePanel:SetVisible( ASS_ShouldShowNoticeBar() )
  700. //end
  701.  
  702. //NoticePanel:AddNotice(NAME, TEXT, DURATION)
  703. end
  704.  
  705. function ASS_RemoveNotice( NAME )
  706.  
  707. if (!NoticePanel) then
  708. return
  709. end
  710.  
  711. NoticePanel:RemoveNotice(NAME)
  712. end
  713.  
  714. function ASS_ToggleNoticeBar( PLAYER, CMD, ARGS )
  715.  
  716. if (ASS_Config["show_notice_bar"] == 0) then
  717. ASS_Config["show_notice_bar"] = 1
  718. else
  719. ASS_Config["show_notice_bar"] = 0
  720. end
  721. ASS_WriteConfig()
  722.  
  723. if (NoticePanel) then
  724. NoticePanel:SetVisible( ASS_ShouldShowNoticeBar() )
  725. end
  726.  
  727. end
  728. concommand.Add("ASS_ToggleNoticeBar", ASS_ToggleNoticeBar)
  729.  
  730. function ASS_Initialize_A()
  731.  
  732. ASS_LoadPlugins()
  733.  
  734. end
  735.  
  736. function ASS_Initialize_B()
  737.  
  738. if (ASS_Initialized) then return end
  739.  
  740. concommand.Add("+ASS_Menu", ASS_ShowMenu)
  741. concommand.Add("-ASS_Menu", ASS_HideMenu)
  742.  
  743. ASS_Init_Shared()
  744.  
  745. ASS_Initialized = true
  746.  
  747. end
  748. concommand.Add("ASS_CS_Initialize", ASS_Initialize_B)
  749.  
  750. usermessage.Hook( "ASS_BannedPlayer",
  751. function(UM)
  752. ASS_IncProgress("ASS_BannedPlayer")
  753. local name = UM:ReadString()
  754. local id = UM:ReadString()
  755.  
  756. name = name .. " (" .. id .. ")"
  757. table.insert( ASS_BannedPlayers, { Text = name, ID = id } )
  758. end
  759. )
  760. usermessage.Hook( "ASS_ShowBannedPlayerGUI",
  761. function(UM)
  762. ASS_EndProgress("ASS_BannedPlayer")
  763. ASS_ShowUnbanList()
  764. end
  765. )
  766. usermessage.Hook( "ASS_NamedCountdown",
  767. function(UM)
  768. ASS_Countdown( UM:ReadString(), UM:ReadString(), UM:ReadFloat() )
  769. end
  770. )
  771. usermessage.Hook( "ASS_Countdown",
  772. function(UM)
  773. ASS_Countdown( nil, UM:ReadString(), UM:ReadFloat() )
  774. end
  775. )
  776. usermessage.Hook( "ASS_RemoveCountdown",
  777. function(UM)
  778. ASS_RemoveCountdown( UM:ReadString() )
  779. end
  780. )
  781. usermessage.Hook( "ASS_NamedNotice",
  782. function(UM)
  783. ASS_Notice( UM:ReadString(), UM:ReadString(), UM:ReadFloat() )
  784. end
  785. )
  786. usermessage.Hook( "ASS_Notice",
  787. function(UM)
  788. ASS_Notice( nil, UM:ReadString(), UM:ReadFloat() )
  789. end
  790. )
  791. usermessage.Hook( "ASS_RemoveNotice",
  792. function(UM)
  793. ASS_RemoveNotice( UM:ReadString() )
  794. end
  795. )
  796. usermessage.Hook( "ASS_BeginProgress",
  797. function(UM)
  798. ASS_BeginProgress( UM:ReadString(), UM:ReadString(), UM:ReadFloat() )
  799. end
  800. )
  801. usermessage.Hook( "ASS_IncProgress",
  802. function(UM)
  803. ASS_IncProgress( UM:ReadString(), UM:ReadFloat() )
  804. end
  805. )
  806. usermessage.Hook( "ASS_EndProgress",
  807. function(UM)
  808. ASS_EndProgress( UM:ReadString() )
  809. end
  810. )
  811.  
  812.  
  813. hook.Add("Initialize", "ASS_Initialize", ASS_Initialize_A)
RAW Paste Data