Advertisement
Guest User

Untitled

a guest
Dec 24th, 2014
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.13 KB | None | 0 0
  1. function BailMenu()
  2. local scrubs
  3. local ArrestFee
  4. local arrestedplayers = {}
  5.  
  6. for key, value in pairs( player.GetAll() ) do
  7. if value:getDarkRPVar( "Arrested" ) then
  8. table.insert( arrestedplayers, value )
  9. end
  10. end
  11.  
  12.  
  13. local BailMain = vgui.Create( "DFrame" )
  14. BailMain:SetSize( 610, 450 )
  15. BailMain:Center()
  16. BailMain:SetDraggable( false )
  17. BailMain:MakePopup()
  18. BailMain:SetTitle( "" )
  19. BailMain:ShowCloseButton( false )
  20. BailMain.Paint = function( self, w, h )
  21. draw.RoundedBox( 0, 0, 0, w, h, Color( 150, 150, 150 ) )
  22. draw.RoundedBox( 0, 1, 1, w - 2, h - 2, Color( 252, 252, 252 ) )
  23.  
  24. surface.SetDrawColor( Color( 224, 224, 224, 255 ) )
  25. surface.DrawLine( 0, 20, w, 50 )
  26.  
  27. draw.RoundedBox( 0, 0, 0, w, 50, Color( 51, 54, 58, 255 ) )
  28.  
  29. draw.RoundedBox( 0, 1, 1, w - 2, 50 - 2, Color( 62, 67, 77 ) )
  30.  
  31. surface.SetDrawColor( Color( 84, 89, 100, 255 ) )
  32. surface.DrawLine( 1, 1, w - 1, 1 )
  33. surface.DrawLine( 1, 1, 1, 50 )
  34. surface.DrawLine( 1, 48, w - 1, 48 )
  35. surface.DrawLine( w - 2, 1, w - 2, 50 )
  36. end
  37.  
  38. local Title = vgui.Create( "DLabel", BailMain )
  39. Title:SetPos( 16, 12 )
  40. Title:SetTextColor( Color( 252, 252, 252 ) )
  41. Title:SetFont( "BailTitleFont" )
  42. Title:SetText( BAIL.WindowTitle or "Bail Bondsman" )
  43. Title:SizeToContents()
  44.  
  45. local cl = vgui.Create( "DButton", BailMain )
  46. cl:SetSize( 50, 20 )
  47. cl:SetPos( BailMain:GetWide() - 60, 0 )
  48. cl:SetText( "X" )
  49. cl:SetFont( "fontclose" )
  50. cl:SetTextColor( Color( 255, 255, 255, 255 ) )
  51. cl.Paint = function( self, w, h )
  52. local kcol
  53. if self.hover then
  54. kcol = Color( 255, 150, 150, 255 )
  55. else
  56. kcol = Color( 175, 100, 100 )
  57. end
  58. draw.RoundedBoxEx( 0, 0, 0, w, h, Color( 255, 150, 150, 255 ), false, false, true, true )
  59. draw.RoundedBoxEx( 0, 1, 0, w - 2, h - 1, kcol, false, false, true, true )
  60. end
  61. cl.DoClick = function()
  62. BailMain:Close()
  63. textOpen = false
  64. net.Start( "Close" )
  65. net.SendToServer()
  66. end
  67. cl.OnCursorEntered = function( self )
  68. self.hover = true
  69. end
  70. cl.OnCursorExited = function( self )
  71. self.hover = false
  72. end
  73.  
  74. local noPlayers = false
  75.  
  76. local function NoArrestedPlayers()
  77. noPlayers = true
  78. local NoPlayers = vgui.Create( "DLabel", BailMain )
  79. NoPlayers:SetText( "The jail is currently empty!" )
  80. NoPlayers:SetFont( "BailNameFont" )
  81. NoPlayers:SetTextColor( Color( 200, 200, 200 ) )
  82. NoPlayers:SizeToContents()
  83. NoPlayers:Center()
  84. end
  85.  
  86. local BailList = vgui.Create( "DPanelList", BailMain )
  87. BailList:SetPos( 10, 60 )
  88. BailList:SetSize( BailMain:GetWide() - 20, BailMain:GetTall() - 80 )
  89. BailList:SetSpacing( 2 )
  90. BailList:EnableVerticalScrollbar( true )
  91. BailList.VBar.Paint = function( s, w, h )
  92. draw.RoundedBox( 4, 3, 13, 8, h-24, Color(0,0,0,70))
  93. end
  94. BailList.VBar.btnUp.Paint = function( s, w, h ) end
  95. BailList.VBar.btnDown.Paint = function( s, w, h ) end
  96. BailList.VBar.btnGrip.Paint = function( s, w, h )
  97. draw.RoundedBox( 4, 5, 0, 4, h+22, Color(0,0,0,70))
  98. end
  99.  
  100. if table.Count( arrestedplayers ) != 0 then
  101. for k, v in pairs( arrestedplayers ) do
  102. local PlayerMain = vgui.Create( "DFrame" )
  103. PlayerMain:SetSize( BailList:GetWide(), 100 )
  104. PlayerMain:ShowCloseButton( false )
  105. PlayerMain:SetTitle( "" )
  106. PlayerMain.Paint = function( self, w, h )
  107.  
  108. local nameFont
  109. local nameOffset
  110.  
  111. surface.SetFont( "BailNameFont" )
  112. local BailName = v:Name()
  113. local Width, Height = surface.GetTextSize(v:Name())
  114. if Width > 100 then
  115. nameFont = "BailNameFontSmall"
  116. nameOffset = 8
  117. else
  118. nameFont = "BailNameFont"
  119. nameOffset = 0
  120. end
  121.  
  122. if nameFont == "BailNameFontSmall" and Width > 100 then
  123. BailName = string.sub( v:Name(), 1, 18 )..".."
  124. end
  125.  
  126. local timeLeft = math.Round(v:GetNWFloat( "ArrestLength" ) - (math.abs(v:GetNWFloat( "TimeArrested" ) - CurTime())))
  127. scrubs = 0
  128. ArrestFee = scrubs * timeLeft
  129. draw.RoundedBox( 0, 0, 0, w, h, Color( 231, 232, 234 ) )
  130. draw.RoundedBox( 0, 1, 1, w - 2, h - 2, Color( 252, 252, 252 ) )
  131. draw.RoundedBox( 4, 14, 14, 66, 66, Color( 140, 140, 140, 255 ) )
  132. draw.SimpleText( BailName, nameFont, 84, 8 + nameOffset, Color( 0, 0, 0 ) )
  133. draw.SimpleText( "Job: "..team.GetName(v:Team()), "BailJobFont", 84, 44, Color( 0, 0, 0, 200 ) )
  134. draw.SimpleText( "Arrested by: "..v:GetNWEntity( "Arrester" ):Name(), "BailJobFont", 84, 62, Color( 0, 0, 0, 200 ) )
  135. draw.SimpleText( "Time Remaining: "..tostring(timeLeft).." seconds", "BailJobFont", w - 140, 14, Color( 0, 0, 0, 255 ), TEXT_ALIGN_RIGHT )
  136. draw.SimpleText( "Fee: $"..tostring(ArrestFee), "BailJobFont", w - 140, 30, Color( 0, 0, 0, 200 ), TEXT_ALIGN_RIGHT )
  137. end
  138. PlayerMain.Think = function()
  139. if not v:getDarkRPVar( "Arrested" ) then
  140. BailList:RemoveItem( PlayerMain )
  141. end
  142. end
  143.  
  144. local ava = vgui.Create( "AvatarImage", PlayerMain )
  145. ava:SetPos( 15, 15 )
  146. ava:SetSize( 64, 64 )
  147. ava:SetPlayer( v, 64 )
  148.  
  149. local icon = vgui.Create("DModelPanel", PlayerMain)
  150. icon:SetPos( PlayerMain:GetWide() - 128, 4 )
  151. local IconModel = v:GetModel()
  152. icon:SetModel(IconModel)
  153. icon:SetSize( 100, 80 )
  154. local ent = icon:GetEntity()
  155. local headPos = ent:GetBonePosition(ent:LookupBone("ValveBiped.Bip01_Head1"))
  156. ent:SetEyeTarget(Vector(20, 00, 65))
  157. icon:SetCamPos(Vector(16, 10, 65))
  158. icon:SetLookAt(headPos)
  159. icon:SetAnimated(false)
  160. function icon:LayoutEntity() end
  161. local oldpaint = icon.Paint
  162. function icon:Paint()
  163.  
  164. local x2, y2 = BailList:LocalToScreen( 0, 0 )
  165. local w2, h2 = BailList:GetSize()
  166. render.SetScissorRect( x2, y2, x2 + w2, y2 + h2, true )
  167.  
  168. oldpaint( self )
  169.  
  170. render.SetScissorRect( 0, 0, 0, 0, false )
  171. end
  172.  
  173. local BailButton = vgui.Create( "DButton", PlayerMain )
  174. BailButton:SetPos( PlayerMain:GetWide() - 114, PlayerMain:GetTall() - 26 )
  175. BailButton:SetSize( 80, 20 )
  176. BailButton:SetDrawOnTop( true )
  177. BailButton:SetTextColor( Color( 255, 255, 255 ) )
  178. BailButton:SetText( "Bail Out" )
  179. BailButton.Paint = function( self, w, h )
  180. local gcol
  181. if self.hover then
  182. gcol = Color( 36, 190, 255 )
  183. else
  184. gcol = Color( 26, 160, 212 )
  185. end
  186. draw.RoundedBox( 0, 0, 0, w, h, Color( 22, 131, 173 ) )
  187. draw.RoundedBox( 0, 1, 1, w - 2, h - 2, gcol )
  188.  
  189. surface.SetDrawColor( Color( 31, 191, 255, 255 ) )
  190. surface.DrawLine( 1, 1, w - 1, 1 )
  191. surface.DrawLine( 1, 1, 1, 20 )
  192. surface.DrawLine( 1, 18, w - 1, 18 )
  193. surface.DrawLine( w - 2, 1, w - 2, 20 )
  194. end
  195. BailButton.DoClick = function( self )
  196. if v:getDarkRPVar( "Arrested" ) == true and LocalPlayer():getDarkRPVar( "money" ) > ArrestFee then
  197.  
  198. net.Start( "BailOut" )
  199. net.WriteEntity( LocalPlayer() )
  200. net.WriteEntity( v )
  201. net.WriteFloat( ArrestFee )
  202. net.SendToServer()
  203.  
  204. BailMain:Close()
  205. if BAIL.PlayBailSound then
  206. surface.PlaySound(BAIL.BailSound)
  207. end
  208. else
  209. chat.AddText( Color( 255, 255, 255 ), "You cannot afford this!" )
  210. end
  211. end
  212. BailList:AddItem( PlayerMain )
  213. end
  214. else
  215. NoArrestedPlayers()
  216. end
  217. end
  218. concommand.Add("bailnpc",BailMenu)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement