Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2016
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.54 KB | None | 0 0
  1.  
  2. include( "shared.lua" )
  3.  
  4. ENT.RenderGroup = RENDERGROUP_BOTH
  5.  
  6. function ENT:Draw()
  7. self:DrawModel()
  8. end
  9.  
  10. local function CommaTheCash( num )
  11. if ( !num ) then return end
  12.  
  13. for i = string.len( num ) - 3, 1, -3 do
  14. num = string.sub( num, 1, i ) .. "," .. string.sub( num, i + 1 )
  15. end
  16. return num
  17. end
  18.  
  19. local function AreWeNearATM()
  20. for id, ent in pairs( ents.FindInSphere( LocalPlayer():GetPos(), 100 ) ) do
  21. if ( ent:GetClass() == "atm_machine" ) then
  22. return true
  23. end
  24. end
  25. return false
  26. end
  27.  
  28. concommand.Add( "rp_atm_nopin", function( ply, cmd, args )
  29. if ( !AreWeNearATM() ) then chat.AddText( "You must be near an ATM to use it!" ) return end
  30. if ( IsValid( DermaPanel5 ) ) then
  31. DermaPanel5:SetVisible( false )
  32. DermaPanel5:Close()
  33. end
  34.  
  35. DermaPanel4 = vgui.Create( "DFrame" )
  36. DermaPanel4:SetSize( 150, 110 )
  37. DermaPanel4:SetTitle( "ATM" )
  38. DermaPanel4:Center()
  39. DermaPanel4:SetSkin("Cortex")
  40. DermaPanel4:MakePopup()
  41. DermaPanel4.Paint = function( self, w, h ) -- 'function Frame:Paint( w, h )' works too
  42. draw.RoundedBox( 0, 0, 0, w, h, Color( 0,0,0, 200 ) )
  43. draw.RoundedBox( 0, 0, 0, w, 25, Color( 73,147,197, 150 ) ) -- Draw a red box instead of the frame
  44. end
  45.  
  46. local DLabel5 = vgui.Create( "DLabel", DermaPanel4 )
  47. DLabel5:SetPos( 26, 25 )
  48. DLabel5:SetColor( Color( 255, 255, 255, 255 ) )
  49. DLabel5:SetFont( "TabLarge" )
  50. DLabel5:SetText( "Please Create a PIN." )
  51. DLabel5:SizeToContents()
  52. DLabel5:SetSkin("Cortex")
  53.  
  54. local DLabel6 = vgui.Create( "DLabel", DermaPanel4 )
  55. DLabel6:SetPos( 37, 40 )
  56. DLabel6:SetColor( Color( 255, 0, 0, 255 ) )
  57. DLabel6:SetFont( "TabLarge" )
  58. DLabel6:SetText( "*4 Digits Only!*" )
  59. DLabel6:SizeToContents()
  60.  
  61. local myText5 = vgui.Create( "DTextEntry", DermaPanel4 )
  62. myText5:SetSize( 80, 20 )
  63. myText5:SetPos( 36, 60 )
  64. myText5:RequestFocus()
  65.  
  66. local button5 = vgui.Create( "DButton", DermaPanel4 )
  67. button5:SetSize( 80, 18 )
  68. button5:SetPos( 36, 85 )
  69. button5:SetText( "Set PIN" )
  70. button5.DoClick = function()
  71. RunConsoleCommand( "rp_atm_setpin", myText5:GetValue() )
  72. end
  73.  
  74. end )
  75.  
  76. concommand.Add( "rp_atm_open", function( ply, cmd, args )
  77. if ( !AreWeNearATM() ) then chat.AddText( "You must be near an ATM to use it!" ) return end
  78.  
  79. if ( IsValid( DermaPanel4 ) ) then
  80. DermaPanel4:SetVisible( false )
  81. DermaPanel4:Close()
  82. end
  83.  
  84. DermaPanel5 = vgui.Create( "DFrame" )
  85. DermaPanel5:SetSize( 160, 250 )
  86. DermaPanel5:SetTitle( "ATM" )
  87. DermaPanel5:Center()
  88. DermaPanel5:MakePopup()
  89. DermaPanel5:SetSkin("Cortex")
  90. DermaPanel5.Paint = function( self, w, h ) -- 'function Frame:Paint( w, h )' works too
  91. draw.RoundedBox( 0, 0, 0, w, h, Color( 0,0,0, 200 ) )
  92. draw.RoundedBox( 0, 0, 0, w, 25, Color( 73,147,197, 150 ) ) -- Draw a red box instead of the frame
  93. end
  94.  
  95. local PropertySheet = vgui.Create( "DPropertySheet", DermaPanel5 )
  96. PropertySheet:SetPos( 0, 25 )
  97. PropertySheet:SetSize( 160, 225 )
  98.  
  99. local TabA = vgui.Create( "DPanelList", PropertySheet )
  100.  
  101. local DLabel1 = vgui.Create( "DLabel", TabA )
  102. DLabel1:SetPos( 24, 20 )
  103. DLabel1:SetColor( Color( 255, 255, 255, 255 ) )
  104. DLabel1:SetFont( "TabLarge" )
  105. DLabel1:SetText( "Select Account:" )
  106. DLabel1:SizeToContents()
  107.  
  108. local List = vgui.Create( "DComboBox", TabA )
  109. List:SetPos( 22, 36 )
  110. List:SetSize( 100, 20 )
  111. List:SetText( LocalPlayer():Nick() )
  112. List.CurData = LocalPlayer():UniqueID()
  113. List.OnSelect = function( self, index, value, data )
  114. List.CurData = data
  115. end
  116. for k, v in pairs( player.GetAll() ) do
  117. List:AddChoice( v:Nick(), v:UniqueID() )
  118. end
  119.  
  120. local DLabel2 = vgui.Create( "DLabel", TabA )
  121. DLabel2:SetPos( 24, 70 )
  122. DLabel2:SetColor( Color( 255, 255, 255, 255 ) )
  123. DLabel2:SetFont( "TabLarge" )
  124. DLabel2:SetText( "Enter PIN:" )
  125. DLabel2:SizeToContents()
  126.  
  127. local myText1 = vgui.Create( "DTextEntry", TabA )
  128. myText1:SetSize( 100, 20 )
  129. myText1:SetPos( 22, 85 )
  130. myText1:RequestFocus()
  131. myText1.OnEnter = function()
  132. RunConsoleCommand( "rp_atm_login", util.CRC( myText1:GetValue() ), List.CurData )
  133. end
  134.  
  135. local button1 = vgui.Create( "DButton", TabA )
  136. button1:SetSize( 100, 18 )
  137. button1:SetPos( 22, 106 )
  138. button1:SetText( "Enter" )
  139. button1:SetTextColor(BColor)
  140. button1.DoClick = function()
  141. RunConsoleCommand( "rp_atm_login", util.CRC( myText1:GetValue() ), List.CurData )
  142. end
  143.  
  144. local button2 = vgui.Create( "DButton", TabA )
  145. button2:SetSize( 100, 25 )
  146. button2:SetPos( 22, 150 )
  147. button2:SetText( "Change my PIN" )
  148. button2:SetTextColor(BColor)
  149. button2.DoClick = function()
  150. RunConsoleCommand( "rp_atm_nopin" )
  151. chat.AddText( color_white, "Security Note: DO NOT USE FREQUENTLY-USED, PERSONAL PASSWORDS." )
  152. end
  153.  
  154. PropertySheet:AddSheet( "ATM", TabA, "icon16/shield.png", false, false, "ATM Security" )
  155.  
  156. /******************************** ADMIN TAB ********************************/
  157.  
  158. if ( !LocalPlayer():IsSuperAdmin() ) then return end
  159.  
  160. local TabB = vgui.Create( "DPanelList", PropertySheet )
  161.  
  162. local button1 = vgui.Create( "DButton", TabB )
  163. button1:SetSize( 120, 18 )
  164. button1:SetPos( 12, 5 )
  165. button1:SetText( "Print PIN Codes" )
  166. button1.DoClick = function()
  167. RunConsoleCommand( "rp_atm_pincodes_send" )
  168. end
  169.  
  170. local button2 = vgui.Create( "DButton", TabB )
  171. button2:SetSize( 120, 18 )
  172. button2:SetPos( 12, 25 )
  173. button2:SetText( "Print Banked Money" )
  174. button2.DoClick = function()
  175. RunConsoleCommand( "rp_atm_money_send" )
  176. end
  177.  
  178. local DLabel2 = vgui.Create( "DLabel", TabB )
  179. DLabel2:SetPos( 20, 48 )
  180. DLabel2:SetColor( Color( 255, 255, 255, 255 ) )
  181. DLabel2:SetFont( "TabLarge" )
  182. DLabel2:SetText( "ATMs:" )
  183. DLabel2:SizeToContents()
  184.  
  185. local button3 = vgui.Create( "DButton", TabB )
  186. button3:SetSize( 70, 18 )
  187. button3:SetPos( 0, 64 )
  188. button3:SetText( "Remove" )
  189. button3:SetTooltip( "Remove all ATMs on the map" )
  190. button3.DoClick = function()
  191. RunConsoleCommand( "rp_atm_removeall" )
  192. end
  193.  
  194. local button4 = vgui.Create( "DButton", TabB )
  195. button4:SetSize( 70, 18 )
  196. button4:SetPos( 0, 84 )
  197. button4:SetText( "Respawn" )
  198. button4:SetTooltip( "Respawn ATMs from a saved file" )
  199. button4.DoClick = function()
  200. RunConsoleCommand( "rp_atm_respawnall" )
  201. end
  202.  
  203. local DLabel2 = vgui.Create( "DLabel", TabB )
  204. DLabel2:SetPos( 86, 48 )
  205. DLabel2:SetColor( Color( 255, 255, 255, 255 ) )
  206. DLabel2:SetFont( "TabLarge" )
  207. DLabel2:SetText( "Spawns:" )
  208. DLabel2:SizeToContents()
  209.  
  210. local button3_add = vgui.Create( "DButton", TabB )
  211. button3_add:SetSize( 70, 18 )
  212. button3_add:SetPos( 72, 64 )
  213. button3_add:SetText( "Save" )
  214. button3_add:SetTooltip( "Save all ATM positions to a file" )
  215. button3_add.DoClick = function()
  216. RunConsoleCommand( "rp_atm_savespawns" )
  217. end
  218.  
  219. local button4_add = vgui.Create( "DButton", TabB )
  220. button4_add:SetSize( 70, 18 )
  221. button4_add:SetPos( 72, 84 )
  222. button4_add:SetText( "Delete" )
  223. button4_add:SetTooltip( "Delete ATM positions for this map" )
  224. button4_add.DoClick = function()
  225. RunConsoleCommand( "rp_atm_removespawns" )
  226. end
  227.  
  228. local List2 = vgui.Create( "DComboBox", TabB )
  229. List2:SetSize( 120, 18 )
  230. List2:SetPos( 12, 116 )
  231. List2:SetText( tostring( LocalPlayer():Nick() ) )
  232. List2.CurData = LocalPlayer():UniqueID()
  233. List2.OnSelect = function( self, index, value, data )
  234. List2.CurData = data
  235. end
  236. for k, v in pairs( player.GetAll() ) do
  237. List2:AddChoice( v:Nick(), v:UniqueID() )
  238. end
  239.  
  240. local myText11 = vgui.Create( "DTextEntry", TabB )
  241. myText11:SetSize( 58, 16 )
  242. myText11:SetPos( 12, 136 )
  243. myText11.OnEnter = function()
  244. RunConsoleCommand( "rp_atm_admin_setpin", List2.CurData, myText11:GetValue() )
  245. end
  246.  
  247. local button5 = vgui.Create( "DButton", TabB )
  248. button5:SetSize( 58, 16 )
  249. button5:SetPos( 74, 136 )
  250. button5:SetText( "Set PIN" )
  251. button5:SetTooltip( "Set PIN for selected account" )
  252. button5.DoClick = function()
  253. RunConsoleCommand( "rp_atm_admin_setpin", List2.CurData, myText11:GetValue() )
  254. end
  255.  
  256. local button6 = vgui.Create( "DButton", TabB )
  257. button6:SetSize( 58, 16 )
  258. button6:SetPos( 12, 154 )
  259. button6:SetText( "Enter Valut" )
  260. button6:SetTooltip( "Enter selected account without entering PIN" )
  261. button6.DoClick = function()
  262. RunConsoleCommand( "rp_atm_admin_account", List2.CurData )
  263. end
  264.  
  265. local button7 = vgui.Create( "DButton", TabB )
  266. button7:SetSize( 58, 16 )
  267. button7:SetPos( 74, 154 )
  268. button7:SetText( "Reset PIN" )
  269. button7:SetTooltip( "Reset PIN for selected account" )
  270. button7.DoClick = function()
  271. RunConsoleCommand( "rp_atm_admin_resetpin", List2.CurData )
  272. end
  273.  
  274. local button8 = vgui.Create( "DButton", TabB )
  275. button8:SetSize( 120, 16 )
  276. button8:SetPos( 12, 172 )
  277. button8:SetText( "Reset Money" )
  278. button8:SetTooltip( "Reset money for selected account" )
  279. button8.DoClick = function()
  280. RunConsoleCommand( "rp_atm_admin_resetmoney", List2.CurData )
  281. end
  282. button1:SetTextColor(BColor)
  283. button2:SetTextColor(BColor)
  284. button3:SetTextColor(BColor)
  285. button4:SetTextColor(BColor)
  286. button3_add:SetTextColor(BColor)
  287. button4_add:SetTextColor(BColor)
  288. button5:SetTextColor(BColor)
  289. button6:SetTextColor(BColor)
  290. button7:SetTextColor(BColor)
  291. button8:SetTextColor(BColor)
  292.  
  293. PropertySheet:AddSheet( "Admin", TabB, "icon16/shield_add.png", false, false, "ATM Admin Settings" )
  294. for k, v in pairs(PropertySheet.Items) do
  295. -- if (!v.Tab) then continue end
  296.  
  297. v.Tab.Paint = function(self,w,h)
  298. draw.RoundedBox(0, 0, 0, w, h, Color(34,34,34))
  299. if v.Tab == PropertySheet:GetActiveTab() then
  300. draw.RoundedBox( 0, 0, 0, w + 4, h + 4, Color( 51, 51, 51 ) )
  301. end
  302. end
  303. end
  304. end)
  305.  
  306. concommand.Add("rp_atm_account",function ( ply, cmd, args )
  307. if ( !AreWeNearATM() ) then chat.AddText( "You must be near an ATM to use it!" ) return end
  308. if ( IsValid( DermaPanel5 ) ) then
  309. DermaPanel5:SetVisible( false )
  310. DermaPanel5:Close()
  311. end
  312.  
  313. if ( IsValid( DermaPanel ) ) then
  314. DermaPanel:SetVisible( false )
  315. DermaPanel:Close()
  316. end
  317.  
  318. DermaPanel = vgui.Create( "DFrame" )
  319. DermaPanel:SetSize( 160, 225 )
  320. DermaPanel:SetTitle( "ATM" )
  321. DermaPanel:Center()
  322. DermaPanel:MakePopup()
  323. DermaPanel:SetSkin("Cortex")
  324. DermaPanel.Paint = function( self, w, h ) -- 'function Frame:Paint( w, h )' works too
  325. draw.RoundedBox( 0, 0, 0, w, h, Color( 0,0,0, 200 ) )
  326. draw.RoundedBox( 0, 0, 0, w, 25, Color( 73,147,197, 150 ) ) -- Draw a red box instead of the frame
  327. end
  328.  
  329. local DLabel7 = vgui.Create( "DLabel", DermaPanel )
  330. DLabel7:SetPos( 20, 30 )
  331. DLabel7:SetColor( Color( 255, 204, 51, 255 ) )
  332. DLabel7:SetFont( "TabLarge" )
  333. DLabel7:SetText( "-BANK ACCOUNT INFO-" )
  334. DLabel7:SizeToContents()
  335.  
  336. local DLabel8 = vgui.Create( "DLabel", DermaPanel )
  337. DLabel8:SetPos( 20, 42 )
  338. DLabel8:SetColor( Color( 51, 204, 255, 255 ) )
  339. DLabel8:SetFont( "TabLarge" )
  340. for k, v in pairs( player.GetAll() ) do
  341. if tostring( v:UniqueID() ) == tostring( args[2] ) then
  342. DLabel8:SetText( v:Nick() )
  343. end
  344. end
  345. DLabel8:SizeToContents()
  346.  
  347. local DLabel9 = vgui.Create( "DLabel", DermaPanel )
  348. DLabel9:SetPos( 20, 54 )
  349. DLabel9:SetColor( Color( 0, 255, 0, 255 ) )
  350. DLabel9:SetFont( "TabLarge" )
  351. DLabel9:SetText( "$" .. CommaTheCash( tonumber( args[3] ) ) )
  352. DLabel9:SizeToContents()
  353.  
  354. local DLabel1 = vgui.Create( "DLabel", DermaPanel )
  355. DLabel1:SetPos( 20, 78 )
  356. DLabel1:SetColor( Color( 255, 255, 255, 255 ) )
  357. DLabel1:SetFont( "TabLarge" )
  358. DLabel1:SetText( "Deposit:" )
  359. DLabel1:SizeToContents()
  360.  
  361. local myText = vgui.Create( "DTextEntry", DermaPanel )
  362. myText:SetSize( 120, 20 )
  363. myText:SetPos( 19, 93 )
  364. myText:RequestFocus()
  365. myText.OnEnter = function()
  366. RunConsoleCommand("rp_atm_deposit", args[1], args[2], tonumber( myText:GetValue() ) )
  367. end
  368.  
  369. local button = vgui.Create( "DButton", DermaPanel )
  370. button:SetSize( 120, 18 )
  371. button:SetPos( 19, 114 )
  372. button:SetText( "Deposit" )
  373. button.DoClick = function()
  374. RunConsoleCommand("rp_atm_deposit", args[1], args[2], tonumber( myText:GetValue() ) )
  375. end
  376. button:SetTextColor(BColor)
  377.  
  378. local DLabel2 = vgui.Create( "DLabel", DermaPanel )
  379. DLabel2:SetPos( 20, 144 )
  380. DLabel2:SetColor( Color( 255, 255, 255, 255 ) )
  381. DLabel2:SetFont( "TabLarge" )
  382. DLabel2:SetText( "Withdraw:" )
  383. DLabel2:SizeToContents()
  384.  
  385. local myText2 = vgui.Create( "DTextEntry", DermaPanel )
  386. myText2:SetSize( 120, 20 )
  387. myText2:SetPos( 19, 159 )
  388. myText2.OnEnter = function()
  389. RunConsoleCommand("rp_atm_withdraw", args[1], args[2], tonumber( myText2:GetValue() ) )
  390. end
  391.  
  392. local button = vgui.Create( "DButton", DermaPanel )
  393. button:SetSize( 120, 20 )
  394. button:SetPos( 19, 180 )
  395. button:SetText( "Withdraw" )
  396. button.DoClick = function()
  397. RunConsoleCommand("rp_atm_withdraw", args[1], args[2], tonumber( myText2:GetValue() ) )
  398. end
  399. button:SetTextColor(BColor)
  400. end )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement