Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --this script acts as the main manager for any banking interactions using the banking_public1 system
- local tArg = {...}
- local Action = tArg[1]
- local Amount = tArg[2]
- settings.load(".settings")
- local BankingFormat = "banking_public1"
- local User = settings.get("os_Username")
- local Path = ("."..User.."_Banking_"..BankingFormat)
- local function EditAccount(X)
- local file = fs.open(Path,"a")
- local Balance = file.readLine()
- Balance = Balance + (Amount * X)
- file.clearLine()
- file.writeLine(Balance)
- file.close()
- settings.set("banking_Balance",Balance)
- end
- local function CreateAccount()
- local file = fs.open(Path,"w")
- file.writeLine(0)
- file.writeLine("")
- file.writeLine("")
- file.close()
- settings.set("banking_Balance",0)
- end
- local function Clean()
- fs.delete(Path)
- settings.set("banking_Balance",0)
- end
- local function Update()
- local file1 = fs.open(Path,"r")
- local file2 = fs.open("."..User.."_Banking_"..tArg[3],"w")
- file2.write(file1.readAll())
- file1.close()
- file2.close()
- fs.delete(Path)
- end
- local function GetBalance()
- local file = fs.open(Path,"r")
- settings.set("banking_Balance",file.readLine())
- end
- if Action == "deposit" then
- EditAccount(1)
- elseif Action == "withdraw" then
- EditAccount(-1)
- elseif Action == "balance" then
- GetBalance()
- elseif Action == "setup" then
- CreateAccount()
- elseif Action == "clean" then
- Clean()
- elseif Action == "update" then
- Update()
- end
- settings.save(".settings")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement