Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- GAMEMODE.CivilProtection = {
- [TEAM_POLICE] = true,
- [TEAM_CHIEF] = true,
- [TEAM_MAYOR] = true,
- }
- local function CreateButton( w, text, icon, doclick )
- text = tostring( text )
- w = tonumber( w ) or 2
- icon = icon and Material( icon ) or false
- doclick = doclick or function() end
- w = w * 173 - ( w-1 ) * 1
- local button = vgui.Create( "DButton" )
- button:SetSize( w, 30 )
- button.Paint = function( self, w, h )
- draw.RoundedBox( 0, 0, 0, w, h, Color( 200, 200, 200 ) )
- if icon then
- surface.SetDrawColor( Color( 200, 200, 200, 255 ) )
- surface.SetMaterial(icon)
- surface.DrawTexturedRect( 8, h/2 - 8, 16, 16 )
- draw.SimpleText( text, "SubItemFont", 8 + w/2, h/2, Color( 0, 0, 0 ), 1, 1 )
- else
- draw.SimpleText(text,"SubItemFont", w/2, h/2, Color( 0, 0, 0 ), 1, 1 )
- end
- return true
- end
- button.DoClick = doclick
- return button
- end
- local function CreateOptions( category )
- actions = vgui.Create( "DPanelList" )
- actions:SetAutoSize( true )
- actions:SetSpacing( 2 )
- actions:SetPadding( 4 )
- actions:EnableHorizontal( true )
- actcontainer = vgui.Create( "DCollapsibleCategory" )
- actcontainer:SetWide( actcontainer:GetParent():GetWide() )
- actcontainer:SetContents( actions )
- actcontainer:SetLabel( category )
- actcontainer:SetAlpha( 0 )
- actcontainer:AlphaTo( 255, 1, 0 )
- local barColor = Config.Colors.BarColor
- if category == "General" then
- actions:AddItem(CreateButton( 2, "Drop Money", "icon16/money_delete.png",
- function() Twerk_StringRequest( "Drop money", "How much money would you like to drop?", "",
- function(a) RunConsoleCommand( "darkrp", "dropmoney", tostring(a) ) end )
- end ) )
- actions:AddItem( CreateButton( 2, "Give Money", "icon16/money_delete.png",
- function() Twerk_StringRequest( "Give money", "How much money would you like to give the player you are looking at?",
- "", function(a) RunConsoleCommand( "darkrp", "givemoney", tostring(a) ) end )
- end ) )
- actions:AddItem(CreateButton( 2, "Drop Weapon", 'icon16/package_go.png', function() RunConsoleCommand("darkrp", "dropweapon") end ) )
- end
- if category == "Roleplay" then
- actions:AddItem(CreateButton( 2, "Change Roleplay Name", "icon16/vcard_edit.png",
- function() Twerk_StringRequest( "Change roleplay name", "What do you want to change your roleplay name to?",
- LocalPlayer():Name() or "", function(a) RunConsoleCommand( "darkrp", "rpname", tostring(a) ) end )
- end ) )
- actions:AddItem( CreateButton( 2, "Custom Job Title", "icon16/vcard_edit.png", function()
- Twerk_StringRequest( "Job title", "What do you want to change your job title to?",
- LocalPlayer():getDarkRPVar( "job" ) or "", function(a) RunConsoleCommand( "darkrp", "job", tostring(a) ) end )
- end ) )
- actions:AddItem(CreateButton( 2, "Demote A Player", "icon16/user_delete.png", function()
- local menu = DermaMenu()
- for _,ply in pairs(player.GetAll()) do
- if ply ~= LocalPlayer() then
- menu:AddOption(ply:Nick(), function()
- Twerk_StringRequest( "Demote reason", "Why would you demote "..ply:Nick().."?", nil, function(a)
- RunConsoleCommand( "darkrp", "demote", tostring( ply:UserID() ), a ) end, function() end )
- end )
- end
- end
- menu:Open()
- end ) )
- actions:AddItem( CreateButton( 2, "Sell All Doors", "icon16/book_delete.png",
- function() RunConsoleCommand( "darkrp", "unownalldoors" )
- end ) )
- end
- if category == "Police" then
- barColor = team.GetColor( TEAM_POLICE )
- actions:AddItem( CreateButton( 2,
- 'Request Warrant',
- 'icon16/script_error.png',
- function()
- local menu = DermaMenu()
- for _,ply in pairs( player.GetAll() ) do
- if ply ~= LocalPlayer() then
- menu:AddOption( ply:Nick(), function()
- Twerk_StringRequest("Warrant", "Why would you warrant "..ply:Nick().."?", nil, function(a)
- RunConsoleCommand("darkrp", "warrant", tostring( ply:UserID() ), a ) end, function() end )
- end )
- end
- end
- menu:Open()
- end ) )
- actions:AddItem( CreateButton( 2,
- 'Make Wanted',
- 'icon16/group_error.png',
- function()
- local menu = DermaMenu()
- for _,ply in pairs( player.GetAll() ) do
- if ply ~= LocalPlayer() then
- menu:AddOption( ply:Nick(), function()
- Twerk_StringRequest( "Warrant", "Why would you make "..ply:Nick().." wanted?", nil,
- function(a) RunConsoleCommand( "darkrp", "wanted", tostring( ply:UserID() ), a ) end,
- function() end )
- end)
- end
- end
- menu:Open()
- end))
- actions:AddItem( CreateButton( 2,
- 'Remove Wanted',
- 'icon16/group_add.png',
- function()
- local menu = DermaMenu()
- for _,ply in pairs( player.GetAll() ) do
- if ply ~= LocalPlayer() then
- menu:AddOption( ply:Nick(), function()
- RunConsoleCommand( "darkrp", "unwanted", tostring( ply:UserID() ) )
- end )
- end
- end
- menu:Open()
- end ) )
- if LocalPlayer():Team() == TEAM_CHIEF or LocalPlayer():IsAdmin() then
- actions:AddItem( CreateButton( 2,
- 'Set Jail Position',
- 'icon16/accept.png',
- function() RunConsoleCommand( "darkrp", "setjailpos" ) end ) )
- actions:AddItem( CreateButton( 2,
- 'Add Jail Position',
- 'icon16/add.png',
- function() RunConsoleCommand("darkrp", "addjailpos") end ) )
- end
- end
- if category == "Mayor" then
- barColor = team.GetColor( TEAM_MAYOR )
- actions:AddItem( CreateButton( 2,
- 'Initiate lockdown',
- 'icon16/bell_add.png',
- function() RunConsoleCommand( "darkrp", "lockdown" ) end ) )
- actions:AddItem( CreateButton( 2,
- 'Stop Lockdown',
- 'icon16/bell_delete.png',
- function() RunConsoleCommand( "darkrp", "unlockdown" ) end ) )
- actions:AddItem( CreateButton( 2,
- 'Initiate Lottery',
- 'icon16/money.png',
- function() RunConsoleCommand( "darkrp", "lottery" ) end ) )
- actions:AddItem( CreateButton( 2,
- 'Place Law Board',
- 'icon16/application.png',
- function() RunConsoleCommand( "darkrp", "placelaws" ) end ) )
- actions:AddItem( CreateButton( 2,
- 'Add Law',
- 'icon16/application_add.png',
- function()
- Twerk_StringRequest( "Add a law", "Type the law you would like to add here.",
- "", function(law) RunConsoleCommand( "darkrp", "addlaw", law ) end )
- end ) )
- actions:AddItem( CreateButton( 2,
- 'Remove Law',
- 'icon16/application_delete.png',
- function()
- Twerk_StringRequest( "Remove a law", "Enter the number of the law you would like to remove here.", "", function(num)
- RunConsoleCommand( "darkrp", "removelaw", num )
- end )
- end ) )
- end
- actcontainer.Paint = function( self, w, h )
- draw.RoundedBox( 0, 0, 0, w, h, barColor )
- end
- return actcontainer
- end
- PANEL = {}
- local newTeam
- local oldTeam
- function PANEL:Init()
- newTeam = LocalPlayer():Team()
- oldTeam = LocalPlayer():Team()
- self:SetSize( 700, 500 )
- self.holder = vgui.Create( "DPanelList", self )
- self.holder:SetWide( self:GetWide() )
- self.holder:SetAutoSize( true )
- self.holder:SetSpacing( 4 )
- self.holder:AddItem( CreateOptions( "General" ) )
- self.holder:AddItem( CreateOptions( "Roleplay" ) )
- self:Refresh()
- end
- function PANEL:Refresh()
- if self.holder.Items[3] and not GAMEMODE.CivilProtection[ LocalPlayer():Team() ] then
- self.holder.Items[3]:Remove()
- end
- if self.holder.Items[4] and not RPExtraTeams[ LocalPlayer():Team() ].mayor then
- self.holder.Items[4]:Remove()
- end
- if RPExtraTeams[ LocalPlayer():Team() ].mayor then
- if not self.holder.Items[3] then
- self.holder:AddItem( CreateOptions( "Police" ) )
- end
- if not self.holder.Items[4] then
- self.holder:AddItem( CreateOptions( "Mayor" ) )
- end
- elseif GAMEMODE.CivilProtection[ LocalPlayer():Team() ] then
- if not self.holder.Items[3] then
- self.holder:AddItem( CreateOptions( "Police" ) )
- end
- end
- end
- function PANEL:Think()
- timer.Simple( 0.5, function()
- newTeam = LocalPlayer():Team()
- if newTeam ~= oldTeam then
- self:Refresh()
- oldTeam = LocalPlayer():Team()
- end
- end )
- end
- function PANEL:Paint() end
- derma.DefineControl("DActionsPage", "", PANEL, "DPanel")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement