My testicles are very confused. Calling ply in a function in which cannot have ply called (LUA > PHP > LUA)

My console says this:
Unique ID to PHP:3141787744
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.

local content = string.Explode("
", 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

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 !.

From **[Player.GetByUniqueID](**: “This will return false if no player is found.”
Make sure you have a valid unique ID there.

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:

print("Rank:" .. content[1])
print("Unique ID from PHP:" .. content[2])

under the function that sends http.Get

print("Unique ID to PHP:" .. ply:UniqueID())

Are you sure the player exists then?

Read my edit.

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]

Read my debug prints.

[lua]lua_run_cl local contents = “poop
a” local content = string.Explode("
", 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?

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.

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

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.

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 "
Windows separates new lines with "
" = carriage return and then new line.
If you made your PHP file with notepad, the lines will be separated with "
" - 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 "
" instead of just "

If the file had been written on a Mac, it’s the opposite - "

Luckily for you, I have many crystal ballz.

“\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.

UniqueIDs are strings

I wish to know, was any of my answers the solution(s) to your problem?

Nope, doesn’t work.

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.

[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.