1. Post #1
    Gold Member
    nofear1999's Avatar
    September 2006
    652 Posts
    My console says this:
    Unique ID to PHP:3141787744
    false
    Rank:2
    Unique ID from PHP:3141787744
    [addons/Nofear/lua/autorun/server/donate.lua:13] attempt to index local 'ply' (a boolean value)

    The false indicates ply.
    Code:
    local content = string.Explode("\n", contents)
    local ply = player.GetByUniqueID(content[2])
    Line 2 on contents is the Unique ID.
    Lua is saying that the ply is a boolean value.

    Before you ask, line 13 is if !ply:IsUserGroup("vip") then
    Reply With Quote Edit / Delete Reply Windows 7 United States Show Events Dumb Dumb x 2Funny Funny x 1Winner Winner x 1 (list)

  2. Post #2
    Always the vGuy.
    vercas's Avatar
    September 2011
    844 Posts
    Are you sure you don't have a previous variable with the same name?
    And are you sure you aren't giving it a boolean value by accident before the 13th line?

    Also try if not ply:IsUserGroup("vip") or if !(ply:IsUserGroup("vip")), because this might be an interpreter glitch.
    And for the sake of Lua, use not instead of !.

    Edit:
    From Player.GetByUniqueID : "This will return false if no player is found."
    Make sure you have a valid unique ID there.

  3. Post #3
    Gold Member
    nofear1999's Avatar
    September 2006
    652 Posts
    Yes, I'm 100% sure, there are no booleans in the code. I have it send the data via PHP http.Get and retrieve it with a httpCallBack. I was already sending data via PHP so I did it this way.
    The UniqueID to and from matches but it is setting it as a boolean and is setting it "false".

    Under httpCallBack:
    Code:
    print(ply)
    print("Rank:" .. content[1])
    print("Unique ID from PHP:" .. content[2])
    under the function that sends http.Get
    Code:
    print("Unique ID to PHP:" .. ply:UniqueID())

  4. Post #4
    "The superior man understands what is right; the inferior man understands what will sell"
    Chessnut's Avatar
    August 2011
    3,556 Posts
    Are you sure the player exists then?

  5. Post #5
    Always the vGuy.
    vercas's Avatar
    September 2011
    844 Posts
    Read my edit.

  6. Post #6
    Gold Member
    nofear1999's Avatar
    September 2006
    652 Posts
    Are you sure the player exists then?
    It sends the UniqueID and it's the same. I'm calling it and my entity exists int hes erver I think.

    Edited:

    Read my edit.
    Read my debug prints.

  7. Post #7
    Dennab
    June 2011
    488 Posts
    lua_run_cl local contents = "poop\n73784763\na" local content = string.Explode("\n", contents) local ply = player.GetByUniqueID(content[2]) print(ply:IsUserGroup("superadmin"),ply:IsSuperAdmin(),content[2])
    Output:  true	true	73784763

    Works fine for me is this garrysmod 13 or garrysmod 12?

  8. Post #8

    April 2012
    64 Posts
    tonumber it
    Reply With Quote Edit / Delete Reply Windows 7 United States Show Events Disagree Disagree x 1 (list)

  9. Post #9
    Always the vGuy.
    vercas's Avatar
    September 2011
    844 Posts
    tonumber it
    I thought of that too, but when I looked at the page, it says it takes a string as the (only) argument, not a number.

    And as I said and the wiki page says, if it's false - the player wasn't found.
    Reply With Quote Edit / Delete Reply Windows 7 Romania Show Events Informative Informative x 1 (list)

  10. Post #10
    skullorz's Avatar
    May 2009
    941 Posts
    When you do your check, as Vercas has stated, do if not ply:IsUserGroup("vip") then
    Using ! next to ply will check to see if ply exists or not, and as such will return false because it's 'not'ed
    Reply With Quote Edit / Delete Reply Windows 8 United States Show Events Dumb Dumb x 2Late Late x 1 (list)

  11. Post #11
    "The superior man understands what is right; the inferior man understands what will sell"
    Chessnut's Avatar
    August 2011
    3,556 Posts
    not and ! are the same exact thing.
    Reply With Quote Edit / Delete Reply Windows 7 United States Show Events Agree Agree x 1 (list)

  12. Post #12
    Gold Member
    nofear1999's Avatar
    September 2006
    652 Posts
    not and ! are the same exact thing.
    ! is just a shorter way of writing it.

    I did print(ply) and it's still saying false so it's nothing with the exclamation mark.

  13. Post #13
    Always the vGuy.
    vercas's Avatar
    September 2011
    844 Posts
    How many times do we have to say?
    If ply is false then the function failed to retrieve the UID.

    I hope you can comprehend the following:

    Linux separates new lines with "\n".
    Windows separates new lines with "\r\n" = carriage return and then new line.
    If you made your PHP file with notepad, the lines will be separated with "\r\n" - and so MIGHT your output be. So your unique ID might end with a "\r" if you have more than two lines. "24234234234\r" is obviously not a valid unique ID.

    To fix this, explode by "\r\n" instead of just "\n".

    If the file had been written on a Mac, it's the opposite - "\n\r".

    Luckily for you, I have many crystal ballz.

    Edit:
    "\r" is not a visible character. Printing it won't make it show up - that's why you can't see it in the console.
    Reply With Quote Edit / Delete Reply Windows 7 Romania Show Events Agree Agree x 1 (list)

  14. Post #14
    Gold Banana
    Banana Lord.'s Avatar
    May 2010
    6,852 Posts
    tonumber it
    UniqueIDs are strings
    Reply With Quote Edit / Delete Reply Windows 7 United States Show Events Late Late x 2 (list)

  15. Post #15
    Always the vGuy.
    vercas's Avatar
    September 2011
    844 Posts
    I wish to know, was any of my answers the solution(s) to your problem?

  16. Post #16
    Gold Member
    nofear1999's Avatar
    September 2006
    652 Posts
    Nope, doesn't work.

  17. Post #17
    Always the vGuy.
    vercas's Avatar
    September 2011
    844 Posts
    Is the player who's UID you have actually playing on the server when you run that?
    Reply With Quote Edit / Delete Reply Windows 7 Romania Show Events Late Late x 1 (list)

  18. Post #18
    SeveredSkull's Avatar
    October 2008
    1,316 Posts
    Is the player who's UID you have actually playing on the server when you run that?
    Seeing as his debug prints were stating they are being pulled from PHP, most likely not.

    Edited:

    A very helpful idea would to actually GIVE US what is being printed by your debugs, rather than just tell us what the debug line is.
    Reply With Quote Edit / Delete Reply Windows Vista United States Show Events Agree Agree x 1 (list)