Advertisement
Guest User

Narc - F4 Menu

a guest
Sep 6th, 2014
337
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.08 KB | None | 0 0
  1. GAMEMODE.CivilProtection = {
  2. [TEAM_POLICE] = true,
  3. [TEAM_CHIEF] = true,
  4. [TEAM_MAYOR] = true,
  5. }
  6.  
  7. local function CreateButton( w, text, icon, doclick )
  8. text = tostring( text )
  9. w = tonumber( w ) or 2
  10. icon = icon and Material( icon ) or false
  11. doclick = doclick or function() end
  12. w = w * 173 - ( w-1 ) * 1
  13.  
  14. local button = vgui.Create( "DButton" )
  15. button:SetSize( w, 30 )
  16. button.Paint = function( self, w, h )
  17. draw.RoundedBox( 0, 0, 0, w, h, Color( 200, 200, 200 ) )
  18. if icon then
  19. surface.SetDrawColor( Color( 200, 200, 200, 255 ) )
  20. surface.SetMaterial(icon)
  21. surface.DrawTexturedRect( 8, h/2 - 8, 16, 16 )
  22. draw.SimpleText( text, "SubItemFont", 8 + w/2, h/2, Color( 0, 0, 0 ), 1, 1 )
  23. else
  24. draw.SimpleText(text,"SubItemFont", w/2, h/2, Color( 0, 0, 0 ), 1, 1 )
  25. end
  26. return true
  27. end
  28. button.DoClick = doclick
  29. return button
  30. end
  31.  
  32. local function CreateOptions( category )
  33. actions = vgui.Create( "DPanelList" )
  34. actions:SetAutoSize( true )
  35. actions:SetSpacing( 2 )
  36. actions:SetPadding( 4 )
  37. actions:EnableHorizontal( true )
  38.  
  39. actcontainer = vgui.Create( "DCollapsibleCategory" )
  40. actcontainer:SetWide( actcontainer:GetParent():GetWide() )
  41. actcontainer:SetContents( actions )
  42. actcontainer:SetLabel( category )
  43. actcontainer:SetAlpha( 0 )
  44. actcontainer:AlphaTo( 255, 1, 0 )
  45.  
  46. local barColor = Config.Colors.BarColor
  47.  
  48. if category == "General" then
  49. actions:AddItem(CreateButton( 2, "Drop Money", "icon16/money_delete.png",
  50. function() Twerk_StringRequest( "Drop money", "How much money would you like to drop?", "",
  51. function(a) RunConsoleCommand( "darkrp", "dropmoney", tostring(a) ) end )
  52. end ) )
  53.  
  54. actions:AddItem( CreateButton( 2, "Give Money", "icon16/money_delete.png",
  55. function() Twerk_StringRequest( "Give money", "How much money would you like to give the player you are looking at?",
  56. "", function(a) RunConsoleCommand( "darkrp", "givemoney", tostring(a) ) end )
  57. end ) )
  58.  
  59. actions:AddItem(CreateButton( 2, "Drop Weapon", 'icon16/package_go.png', function() RunConsoleCommand("darkrp", "dropweapon") end ) )
  60. end
  61.  
  62. if category == "Roleplay" then
  63. actions:AddItem(CreateButton( 2, "Change Roleplay Name", "icon16/vcard_edit.png",
  64. function() Twerk_StringRequest( "Change roleplay name", "What do you want to change your roleplay name to?",
  65. LocalPlayer():Name() or "", function(a) RunConsoleCommand( "darkrp", "rpname", tostring(a) ) end )
  66. end ) )
  67.  
  68. actions:AddItem( CreateButton( 2, "Custom Job Title", "icon16/vcard_edit.png", function()
  69. Twerk_StringRequest( "Job title", "What do you want to change your job title to?",
  70. LocalPlayer():getDarkRPVar( "job" ) or "", function(a) RunConsoleCommand( "darkrp", "job", tostring(a) ) end )
  71. end ) )
  72.  
  73. actions:AddItem(CreateButton( 2, "Demote A Player", "icon16/user_delete.png", function()
  74. local menu = DermaMenu()
  75. for _,ply in pairs(player.GetAll()) do
  76. if ply ~= LocalPlayer() then
  77. menu:AddOption(ply:Nick(), function()
  78. Twerk_StringRequest( "Demote reason", "Why would you demote "..ply:Nick().."?", nil, function(a)
  79. RunConsoleCommand( "darkrp", "demote", tostring( ply:UserID() ), a ) end, function() end )
  80. end )
  81. end
  82. end
  83. menu:Open()
  84. end ) )
  85.  
  86. actions:AddItem( CreateButton( 2, "Sell All Doors", "icon16/book_delete.png",
  87. function() RunConsoleCommand( "darkrp", "unownalldoors" )
  88. end ) )
  89. end
  90.  
  91. if category == "Police" then
  92. barColor = team.GetColor( TEAM_POLICE )
  93. actions:AddItem( CreateButton( 2,
  94. 'Request Warrant',
  95. 'icon16/script_error.png',
  96. function()
  97. local menu = DermaMenu()
  98. for _,ply in pairs( player.GetAll() ) do
  99. if ply ~= LocalPlayer() then
  100. menu:AddOption( ply:Nick(), function()
  101. Twerk_StringRequest("Warrant", "Why would you warrant "..ply:Nick().."?", nil, function(a)
  102. RunConsoleCommand("darkrp", "warrant", tostring( ply:UserID() ), a ) end, function() end )
  103. end )
  104. end
  105. end
  106. menu:Open()
  107. end ) )
  108.  
  109. actions:AddItem( CreateButton( 2,
  110. 'Make Wanted',
  111. 'icon16/group_error.png',
  112. function()
  113. local menu = DermaMenu()
  114. for _,ply in pairs( player.GetAll() ) do
  115. if ply ~= LocalPlayer() then
  116. menu:AddOption( ply:Nick(), function()
  117. Twerk_StringRequest( "Warrant", "Why would you make "..ply:Nick().." wanted?", nil,
  118. function(a) RunConsoleCommand( "darkrp", "wanted", tostring( ply:UserID() ), a ) end,
  119. function() end )
  120. end)
  121. end
  122. end
  123. menu:Open()
  124. end))
  125. actions:AddItem( CreateButton( 2,
  126. 'Remove Wanted',
  127. 'icon16/group_add.png',
  128. function()
  129. local menu = DermaMenu()
  130. for _,ply in pairs( player.GetAll() ) do
  131. if ply ~= LocalPlayer() then
  132. menu:AddOption( ply:Nick(), function()
  133. RunConsoleCommand( "darkrp", "unwanted", tostring( ply:UserID() ) )
  134. end )
  135. end
  136. end
  137. menu:Open()
  138. end ) )
  139. if LocalPlayer():Team() == TEAM_CHIEF or LocalPlayer():IsAdmin() then
  140. actions:AddItem( CreateButton( 2,
  141. 'Set Jail Position',
  142. 'icon16/accept.png',
  143. function() RunConsoleCommand( "darkrp", "setjailpos" ) end ) )
  144. actions:AddItem( CreateButton( 2,
  145. 'Add Jail Position',
  146. 'icon16/add.png',
  147. function() RunConsoleCommand("darkrp", "addjailpos") end ) )
  148. end
  149. end
  150.  
  151. if category == "Mayor" then
  152. barColor = team.GetColor( TEAM_MAYOR )
  153. actions:AddItem( CreateButton( 2,
  154. 'Initiate lockdown',
  155. 'icon16/bell_add.png',
  156. function() RunConsoleCommand( "darkrp", "lockdown" ) end ) )
  157.  
  158. actions:AddItem( CreateButton( 2,
  159. 'Stop Lockdown',
  160. 'icon16/bell_delete.png',
  161. function() RunConsoleCommand( "darkrp", "unlockdown" ) end ) )
  162.  
  163. actions:AddItem( CreateButton( 2,
  164. 'Initiate Lottery',
  165. 'icon16/money.png',
  166. function() RunConsoleCommand( "darkrp", "lottery" ) end ) )
  167.  
  168. actions:AddItem( CreateButton( 2,
  169. 'Place Law Board',
  170. 'icon16/application.png',
  171. function() RunConsoleCommand( "darkrp", "placelaws" ) end ) )
  172.  
  173. actions:AddItem( CreateButton( 2,
  174. 'Add Law',
  175. 'icon16/application_add.png',
  176. function()
  177. Twerk_StringRequest( "Add a law", "Type the law you would like to add here.",
  178. "", function(law) RunConsoleCommand( "darkrp", "addlaw", law ) end )
  179. end ) )
  180.  
  181. actions:AddItem( CreateButton( 2,
  182. 'Remove Law',
  183. 'icon16/application_delete.png',
  184. function()
  185. Twerk_StringRequest( "Remove a law", "Enter the number of the law you would like to remove here.", "", function(num)
  186. RunConsoleCommand( "darkrp", "removelaw", num )
  187. end )
  188. end ) )
  189. end
  190.  
  191. actcontainer.Paint = function( self, w, h )
  192. draw.RoundedBox( 0, 0, 0, w, h, barColor )
  193. end
  194.  
  195. return actcontainer
  196. end
  197.  
  198. PANEL = {}
  199.  
  200. local newTeam
  201. local oldTeam
  202.  
  203. function PANEL:Init()
  204. newTeam = LocalPlayer():Team()
  205. oldTeam = LocalPlayer():Team()
  206.  
  207. self:SetSize( 700, 500 )
  208. self.holder = vgui.Create( "DPanelList", self )
  209. self.holder:SetWide( self:GetWide() )
  210. self.holder:SetAutoSize( true )
  211. self.holder:SetSpacing( 4 )
  212. self.holder:AddItem( CreateOptions( "General" ) )
  213. self.holder:AddItem( CreateOptions( "Roleplay" ) )
  214. self:Refresh()
  215. end
  216.  
  217. function PANEL:Refresh()
  218. if self.holder.Items[3] and not GAMEMODE.CivilProtection[ LocalPlayer():Team() ] then
  219. self.holder.Items[3]:Remove()
  220. end
  221. if self.holder.Items[4] and not RPExtraTeams[ LocalPlayer():Team() ].mayor then
  222. self.holder.Items[4]:Remove()
  223. end
  224.  
  225. if RPExtraTeams[ LocalPlayer():Team() ].mayor then
  226. if not self.holder.Items[3] then
  227. self.holder:AddItem( CreateOptions( "Police" ) )
  228. end
  229. if not self.holder.Items[4] then
  230. self.holder:AddItem( CreateOptions( "Mayor" ) )
  231. end
  232. elseif GAMEMODE.CivilProtection[ LocalPlayer():Team() ] then
  233. if not self.holder.Items[3] then
  234. self.holder:AddItem( CreateOptions( "Police" ) )
  235. end
  236. end
  237. end
  238.  
  239. function PANEL:Think()
  240. timer.Simple( 0.5, function()
  241. newTeam = LocalPlayer():Team()
  242. if newTeam ~= oldTeam then
  243. self:Refresh()
  244. oldTeam = LocalPlayer():Team()
  245. end
  246. end )
  247. end
  248.  
  249. function PANEL:Paint() end
  250.  
  251. derma.DefineControl("DActionsPage", "", PANEL, "DPanel")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement