Posted 20 November 2015 - 04:45 AM
I have a file that is full of usernames and I want to be able to search that file for existing users and be able to add users to that file without their being any duplicates/spaces. Currently I'm using this doctored bit of code to search the file system but I'm having a problem adding other usernames using this system. Any help is appreciated.
name = "playername"
if fs.exists("users") then
local file = fs.open("users", "r")
local content = {}
for line in file.readLine do
if line:find(name) then
print("Player Has Been Found.")
end
end
file.close()
end
I figured doing this would work, but I'm having no luck.
name = "playername"
if fs.exists("users") then
local file = fs.open("users", "r")
local content = {}
for line in file.readLine do
if line:find(name) then
print("Player Has Been Found.")
else
local file = fs.open("users", "a")
file.writeLine(name)
file.close()
end
end
file.close()
end