Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --standardized Banking System Interaction Script
- --this program allows the device it is installed on to interact with the ingame banking system
- --this script is for CC Tweaked minecraft 1.16.5
- AccountBalance = AccountBalance
- local tArg = {...}
- local Amount = tArg[1]
- local AccountID = tArg[2]
- local AccountKey = tArg[3]
- local TargetAccount = tArg[4]
- local Method = tArg[5]
- local Serverid = nil
- local CryptionCharacter_Base = ["space","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9","\n","_"]
- local CryptionCharacter_Locked = ["00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35"]
- EncryptedData = nil
- Transfer()
- function Transfer()
- rednet.open()
- local id = rednet.lookup(8452,"BankingServer")
- Serverid = id
- if Method == "Details" then
- Encryption_TypeB("r_"..AccountID,"Encrypt")
- rednet.Send(Serverid,EncryptedData,8452)
- rednet.Send(Serverid,AccountID,8452)
- repeat
- local id, message = rednet.receive()
- until id == Serverid
- if message == "failed" or message == "Declined" then
- print("failed to Get Details")
- else
- Amount = message
- Encryption_TypeB(Amount,"Decrypt")
- AccountBalance = EncryptedData
- end
- elseif Method == "Transfer" then
- Encryption_TypeB("t_"..AccountID,"Encrypt")
- rednet.Send(Serverid,EncryptedData,8452)
- rednet.Send(Serverid,AccountID,8452)
- repeat
- local id, message = rednet.receive()
- until id == Serverid
- if message == "failed" or message == "Declined" then
- print("failed Transfer")
- else
- rednet.send(Serverid,TargetAccount,8452)
- repeat
- local id, message = rednet.receive()
- until id == Serverid
- if message == "Account Not Found" then
- elseif message == "Account Found" then
- rednet.send(Serverid,Amount,8452)
- repeat
- local id, message = rednet.receive
- until id == Serverid
- if message == "Denied" then
- print("Transfer Denied by Bank")
- else
- print("Transfer Accepted")
- AccountBalance = AccountBalance - Amount
- end
- sleep(10)
- end
- end
- elseif Method == "NewAccount" then
- rednet.send(Serverid,"NewAccount",8452)
- rednet.send(Serverid,AccountID,8452)
- repeat
- local id, message = rednet.receive()
- until id == Serverid
- if message == "Denied" then
- print("Account Denied")
- else
- AccountKey = message
- repeat
- local id, message = rednet.receive()
- until id == Serverid
- local BankName = message
- print("Account ID = "..AccountID)
- print("Account Key = "..AccountKey)
- print("Bank Name = "..BankName)
- if TargetAccount == "n" then
- print("Details not saved due to device not allowed to save Account")
- else
- local file = fs.open(TargetAccount,"w")
- file.writeLine(AccountID)
- file.writeLine(AccountKey)
- file.writeLine(BankName)
- file.writeLine(os.date(IRL))
- file.close()
- print("Account Details saved to local file")
- end
- sleep(15)
- end
- end
- end
- function Encryption_TypeB(data,mode)
- data = string.lowerCase(data)
- local Result = ""
- if mode == "Encrypt" then
- Result = "B_"
- for i = 1, #data.bytes do
- local n = 1
- for n = 1, #CryptionCharacter_Base do
- if substring(data,i,i) == CryptionCharacter_Base[n] then
- Result = Result..CryptionCharacter_Locked[n+AccountKey]
- end
- end
- end
- EncryptedData = Result
- elseif mode == "Decrypt" then
- Result = ""
- for i = 1, #data.bytes do
- local n = 1
- for n = 1, #CryptionCharacter_Base do
- if substring(data,i,i) == CryptionCharacter_Locked[n] then
- if CryptionCharacter_Base[n-AccountKey] == "space" then
- Result = Result.." "
- else
- Result = Result..CryptionCharacter_Base[n-AccountKey]
- end
- end
- end
- end
- EncryptedData = Result
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement