This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
pcking911's profile picture

Need help whit multi users

Started by pcking911, 14 December 2012 - 05:34 AM
pcking911 #1
Posted 14 December 2012 - 06:34 AM
hi i got a problem whit when i use like if UP == {User1, User2, User3 } then
but it dosent work i just get password denyed from my code


GPass = "tekkit is awsome"
User1 = "1a2b3c4d5e"
User2 = "lol1"
User3 = "ARE YOU FUCKING CRAZY!?"

shell.run("clear")
print("Master Lock Version: 1.0")
print("")
print("")
write("Group Password: ")
GP = read("*")
if GP == GPass then
textutils.slowPrint("Password: is sending to server for checking…")
sleep(5)
textutils.slowPrint("Password is appceppted!")
else
textutils.slowPrint("Password: is sending to server for checking…")
sleep(5)
textutils.slowPrint("Password is denyed")
os.shutdown()
end
print("now login whit your password")
sleep(2)
shell.run("clear")
write("User Password: ")
UP = read("*")
if UP == {User1, User2, User3 } then
textutils.slowPrint("Password: is sending to server for checking…")
sleep(5)
textutils.slowPrint("Password is appceppted!")
shell.run("back", "true")
sleep(5)
shell.run("back", "false")
os.shutdown()
else
textutils.slowPrint("Password: is sending to server for checking…")
sleep(5)
textutils.slowPrint("Password is denyed")
os.shutdown()
end
Orwell #2
Posted 14 December 2012 - 06:46 AM
You should post the error message next time. But the problem is that you're comparing a string against a table there. You want to know if the username is IN that table, not if it's the same.
Quickest way to do this is to define a table containing all usernames. So at the top, you'd put:

local Users = {
"1a2b3c4d5e"=true,
"lol1"=true,
"ARE YOU FUCKING CRAZY!?"=true,
}

And then replace the line

if UP == {User1, User2, User3 } then
with:

if Users[UP] then

I would personally use sets, you can read about that in the PIL:
http://www.lua.org/pil/11.5.html
pcking911 #3
Posted 14 December 2012 - 09:25 AM
bios:206: [string "startup"]:4: '}' expected (to close '{' at line 3)
dissy #4
Posted 14 December 2012 - 12:22 PM
bios:206: [string "startup"]:4: '}' expected (to close '{' at line 3)

Remove the comma at the end of the last line.
Orwell #5
Posted 14 December 2012 - 12:27 PM
bios:206: [string "startup"]:4: '}' expected (to close '{' at line 3)

Remove the comma at the end of the last line.

I don't think that's an issue actually (if I remember right, textutils.serialize does that too), but the error does indeed say something like that.