Emuq

Get Balance

Aug 25th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.54 KB | None | 0 0
  1. --- Get user balance
  2.  
  3. args = {...}
  4.  
  5. if not #args == 1 then return false end
  6.  
  7. local file = fs.open("banking/database/users", "r")
  8.  
  9. if file then
  10.       tLines = {}
  11.       sLine = file.readLine()
  12.       while sLine do
  13.         table.insert(tLines, sLine)
  14.         sLine = file.readLine()
  15.       end
  16.       file.close()
  17.  end
  18.  
  19. for i = 1, #tLines do
  20.     if string.find(tLines[i], args[1]) then
  21.         local d = {}
  22.         for word in string.gmatch(tLines[i], "([^:]+)") do
  23.             table.insert(d,word)
  24.         end
  25.         return d[2]
  26.     end
  27. end
  28.  
  29. return false
Add Comment
Please, Sign In to add comment