Advertisement
Marlingaming

Token API

Oct 22nd, 2022 (edited)
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. local FilePath = "n"
  2. local Key = "23"
  3.  
  4. local function GetPath()
  5. FilePath = fs.find(".Secured_Token2")
  6. end
  7.  
  8. GetPath()
  9.  
  10. function GetBalance()
  11. local Path = fs.combine(FilePath,".Secured_Token2","Gold")
  12. local Tokens = fs.list(Path)
  13. local balance = 0
  14. for i = 1, #Tokens do
  15. local file = fs.open(fs.combine(Path,Tokens[i]),"r")
  16. local Line = file.readAll()
  17. if string.find(Line,Key) == true then
  18. balance = balance + 1
  19. end
  20. file.close()
  21. end
  22. return balance
  23. end
  24.  
  25. function transferToken(amount)
  26. if GetBalance() >= amount then
  27. local Path = fs.combine(FilePath,".Secured_Token2","Gold")
  28. local Coin = fs.list(Path)
  29. local Table = {}
  30. for i = 1, amount do
  31. local file2 = fs.open(fs.combine(Path,Coin[i]),"r")
  32. local content = file2.readall()
  33. file2.close()
  34. fs.delete(fs.combine(Path,Coin[i]))
  35. Table[i] = {Coin[i],content}
  36. end
  37.  
  38. return Table
  39. else
  40. return false
  41. end
  42. end
  43.  
  44. function DownloadToken(name,code)
  45. local path = fs.combine(FilePath,".Secured_Token2","Gold")
  46. local Item = fs.open(fs.combine(path,name),"w")
  47. Item.write(code)
  48. Item.close()
  49. return true
  50. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement