• My testicles are very confused. Calling ply in a function in which cannot have ply called (LUA > PHP
    17 replies, posted
  • Avatar of nofear1999
  • 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]) [/CODE] 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
  • Avatar of vercas
  • 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 [I]if not ply:IsUserGroup("vip")[/I] or [i]if !(ply:IsUserGroup("vip"))[/i], because this might be an interpreter glitch. And for the sake of Lua, use [i]not[/i] instead of [i]![/i]. [b]Edit[/b]: From [b][url=http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index32d6.html?title=Player.GetByUniqueID]Player.GetByUniqueID [img]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/favicon.ico[/img][/url][/b]: "This will return false if no player is found." Make sure you have a valid unique ID there.
  • Avatar of nofear1999
  • 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])[/CODE] under the function that sends http.Get [code] print("Unique ID to PHP:" .. ply:UniqueID())[/code]
  • Avatar of nofear1999
  • [QUOTE=Chessnut;36079032]Are you sure the player exists then?[/QUOTE] It sends the UniqueID and it's the same. I'm calling it and my entity exists int hes erver I think. [editline]24th May 2012[/editline] [QUOTE=vercas;36079232]Read my edit.[/QUOTE] Read my debug prints.
  • [lua]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[/lua] Works fine for me is this garrysmod 13 or garrysmod 12?
  • Avatar of vercas
  • [QUOTE=Lord Derp;36081070]tonumber it[/QUOTE] 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.
  • 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
  • Avatar of nofear1999
  • [QUOTE=Chessnut;36083253]not and ! are the same exact thing.[/QUOTE] ! 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.
  • Avatar of vercas
  • How many times do we have to say? If [i]ply[/i] is [i]false[/i] 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 [b]and then[/b] 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. [b]Edit[/b]: "\r" is [b]not[/b] a visible character. Printing it won't make it show up - that's why you can't see it in the console.
  • Avatar of vercas
  • I wish to know, was any of my answers the solution(s) to your problem?
  • Avatar of vercas
  • Is the player who's UID you have actually playing on the server when you run that?
  • Avatar of SeveredSkull
  • [QUOTE=vercas;36131142]Is the player who's UID you have actually playing on the server when you run that?[/QUOTE] Seeing as his debug prints were stating they are being pulled from PHP, most likely not. [editline]1st June 2012[/editline] 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.