Advertisement
Marlingaming

CC Tweaked Banking Service Manager - banking_public1

Jan 19th, 2022 (edited)
512
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --this script acts as the main manager for any banking interactions using the banking_public1 system
  2. local tArg = {...}
  3. local Action = tArg[1]
  4. local Amount = tArg[2]
  5. settings.load(".settings")
  6. local BankingFormat = "banking_public1"
  7. local User = settings.get("os_Username")
  8. local Path = ("."..User.."_Banking_"..BankingFormat)
  9.  
  10. local function EditAccount(X)
  11. local file = fs.open(Path,"a")
  12. local Balance = file.readLine()
  13. Balance = Balance + (Amount * X)
  14. file.clearLine()
  15. file.writeLine(Balance)
  16. file.close()
  17. settings.set("banking_Balance",Balance)
  18. end
  19.  
  20. local function CreateAccount()
  21.  
  22. local file = fs.open(Path,"w")
  23. file.writeLine(0)
  24. file.writeLine("")
  25. file.writeLine("")
  26. file.close()
  27. settings.set("banking_Balance",0)
  28. end
  29.  
  30. local function Clean()
  31. fs.delete(Path)
  32. settings.set("banking_Balance",0)
  33. end
  34.  
  35. local function Update()
  36. local file1 = fs.open(Path,"r")
  37. local file2 = fs.open("."..User.."_Banking_"..tArg[3],"w")
  38. file2.write(file1.readAll())
  39. file1.close()
  40. file2.close()
  41. fs.delete(Path)
  42. end
  43.  
  44. local function GetBalance()
  45. local file = fs.open(Path,"r")
  46. settings.set("banking_Balance",file.readLine())
  47. end
  48.  
  49. if Action == "deposit" then
  50.     EditAccount(1)
  51. elseif Action == "withdraw" then
  52.     EditAccount(-1)
  53. elseif Action == "balance" then
  54.     GetBalance()
  55. elseif Action == "setup" then
  56.     CreateAccount()
  57. elseif Action == "clean" then
  58.     Clean()
  59. elseif Action == "update" then
  60.     Update()
  61. end
  62. settings.save(".settings")
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement