Jump to content




[Fixed]isAdmin not working correctly


  • You cannot reply to this topic
4 replies to this topic

#1 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 11 April 2014 - 12:46 PM

OS
Installer
I am trying to get the login function to work properly, but it is *apparently* returning an incorrect value. The problem may be in my loadFile function, or the fact that ... is already an array when it is called, thus turining it into this: {{...}} if that's possible. I don't know how to correct this, as I don't know how many users I will have.
edit: I think the problem lies in the OS itself, but the installer could be to blame. The lines marked as comments are marked as such on purpose, because they would either not work until I finalize it, or would mess with testing.
edit 2: a better description of the problem:
I log in just fine, but it then refuses to use anything other than the logout, because the username returned wasn't in Viewer or Admin (I checked manually and my username was in the Admin file)

Edited by KingofGamesYami, 12 April 2014 - 11:16 PM.


#2 OReezy

  • Members
  • 91 posts

Posted 11 April 2014 - 03:11 PM

Without indentation its hard to follow your code but I did look at your loadFile() and two things stand out to me:
local data = file:read()
Looking at the wiki, the read() function is only usable in binary read mode ("rb"). For the normal read mode ("r"), you have readLine() and readAll() Although I'm pretty sure it would give you an attempt to call nil error if this was the case. Have you tried printing the variable to verify its getting the value you think its getting?

Also, textutils.unserialize() is used for tables. If your file doesn't contain a table that could be an issue too.

Edit: Looked again at the isAdmin() and the second thing shouldn't be an issue.

Edited by OReezy, 11 April 2014 - 03:30 PM.


#3 CometWolf

  • Members
  • 1,283 posts

Posted 11 April 2014 - 04:20 PM

View PostOReezy, on 11 April 2014 - 03:11 PM, said:

I did look at your loadFile() and two things stand out to me:
local data = file:read()
Looking at the wiki, the read() function is only usable in binary read mode ("rb"). For the normal read mode ("r"), you have readLine() and readAll() Although I'm pretty sure it would give you an attempt to call nil error if this was the case. Have you tried printing the variable to verify its getting the value you think its getting?
Note that he uses the io API, not fs. io.read is pretty much equivalent to fs.readLine.
http://www.lua.org/m...manual.html#5.7
Though confirming that it's loading correctly is probably not a bad idea either way.

#4 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 11 April 2014 - 10:10 PM

Sorry for not replying earlier, I was in school all day...
Anyway, I know the textutils.unserialize isn't the problem, as I store all my data (that needs saving) in tables.
PS: Sorry about the indents, the forum does this to me ever time I post code >,<

#5 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 12 April 2014 - 12:59 AM

Quote

local function isViewer(User)
.
.
.
if v == UserLogin then

View PostKingofGamesYami, on 11 April 2014 - 10:10 PM, said:

PS: Sorry about the indents, the forum does this to me ever time I post code >,<

Disable the rich-text editor before pasting (use the little light switch toggle at the upper-left of the posting window).

Edited by Bomb Bloke, 12 April 2014 - 01:01 AM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users