I'm using php to get all the steam members in my group and convert all their community ids to steam ids and set it in a json string. This works fine and all the ids are put into the body of the PHP doc, but when I use [URL="http://wiki.garrysmod.com/page/http/Fetch"]http.Fetch[/URL] to transfer them all to lua and convert them from json to a lua table it doesn't work. I did some testing and it doesn't work because it cuts half of the string off.
Is this a limitation with string lengths or http.Fetch? If its a string limitation, is there any recomendations on what I can do?
You can do all that within GMod, without PHP, question is, why would you need to?
Well I was under the impression that steam api for groups is still outdated as in; you can only get their community ids [URL="https://partner.steamgames.com/documentation/community_data"][1][/URL] [URL="http://steamcommunity.com/groups/Valve/memberslistxml/?xml=1"][2][/URL][URL="https://developer.valvesoftware.com/wiki/Steam_Web_API#Community_data"][4] [/URL]and that you can't directly get their steam ids. I would convert the numbers from within gmod, but apparantly you can't convert their ids to steam ids because of large numbers [URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index5741-2.html"][3][/URL]. So I was using PHP as the middle man to convert it as I know It can handle the numbers. Reason being I can check if a user is in the group if so do this, if not do that.
[4] [QUOTE]Community data
The Steam community data interface (XML only) is described here: [url]https://partner.steamgames.com/documentation/community_data[/url][/QUOTE]
Well, Garry added a function to do that actually. Cant remember if it actually works, was backwards for a while after he added it. [url]http://wiki.garrysmod.com/page/util/SteamIDFrom64[/url]
You can just do search in [URL="http://steamcommunity.com/groups/Valve/memberslistxml/?xml=1"]the[/URL] [URL="http://steamcommunity.com/gid/103582791429521412/memberslistxml/?xml=1"]group[/URL] their [URL="http://wiki.garrysmod.com/page/Player/SteamID64"]Player:SteamID64()[/URL]
[editline]15th February 2014[/editline]
P.S. Don't use old wiki, at least search in the new one before going to the old one.
[QUOTE=Fuzzy5;43920578]Well, Garry added a function to do that actually. Cant remember if it actually works, was backwards for a while after he added it. [url]http://wiki.garrysmod.com/page/util/SteamIDFrom64[/url][/QUOTE]
Thanks for this, but that still doesn't change the fact I have to use the http function to get their ids first, but it still cuts it half way.
[QUOTE=Robotboy655;43920617]You can just do search in group. [/QUOTE]
How would I do this without using fetch?
Take a look at this: [url]http://www.facepunch.com/threads/961117[/url]
Not sure if it works for GM13 though.
I did some tests with the http.Fetch, it seems that print is capped at 4096 symbols, printing body of google.com resulted in 4096 characters, printing length of body resulted in 11400+ characters.
[QUOTE=Robotboy655;43920924]I did some tests with the http.Fetch, it seems that [B]print is capped[/B] at 4096 symbols, printing body of google.com resulted in 4096 characters, printing length of body resulted in 11400+ characters.[/QUOTE]
Surely if it was only print that is limited, It would be fine to use it in a variable and then put it into a table. That is not the case though, as it doesn't reach the end, even when put through util.JSONtoTable as the table isn't valid.
This also brings me back to the original question; Which one is limited? Strings or fetch? You did the same tests as me; printing body of google.com resulted in 4096 characters, printing length of body resulted in 11400+ characters, as well as the actual length that is returned by the function is 11400+. This is why It confused me, because I assume that the string is holding the data, but its not but the length is the actual length.
Here's example of searching first player in my steam group:
[code]http.Fetch( "http://steamcommunity.com/groups/rb655_fans/memberslistxml/?xml=1",function( body, len, headers, code )
print( string.find (body, Entity(1):SteamID64() ) )
end )[/code]
[editline]15th February 2014[/editline]
[QUOTE=Alig96;43920974]Surely if it was only print that is limited, It would be fine to use it in a variable and then put it into a table. That is not the case though, as it doesn't reach the end, even when put through util.JSONtoTable as the table isn't valid.
This also brings me back to the original question; Which one is limited? Strings or fetch? You did the same tests as me; printing body of google.com resulted in 4096 characters, printing length of body resulted in 11400+ characters, as well as the actual length that is returned by the function is 11400+. This is why It confused me, because I assume that the string is holding the data, but its not but the length is the actual length.[/QUOTE]
Show me your code, what you try to convert from JSON.
[editline]15th February 2014[/editline]
Search myself in gamebanana steam group, 11000+ members:
[code]
http.Fetch( "http://steamcommunity.com/groups/gamebanana/memberslistxml/?xml=1",function( body, len, headers, code )
print( string.find( body, Entity(1):SteamID64() ) )
end )[/code]
[lua]
//Group Members
local htmlgmem = ""; -- Blankness
http.Fetch( "http://ttt1.sperpes.com/gmod/members.php",
function( body, len, headers, code )
local gmembers = {"ERROR"}
//Verify that the it has actual data in the string
if string.find(body,"68384425") != nil then
gmembers = util.JSONToTable( body )
end
end,
function( error )
-- We failed. =(
end
)
PrintTable(gmembers)
[/lua]
The PrintTable errors as it did find the data in the check, and tries to overwrite it.
I see now that your method is better, I will probably use that but, I'm still curious as to why my method didn't work.
The reason why I wanted to do it like this, is so on map change, it would only fetch once, then I could just search the table instead of doing multiple fetch requests.
Probably because the variable gmembers is local and inaccessible from outside that function.
[QUOTE=Robotboy655;43921524]Probably because the variable gmembers is local and inaccessible from outside that function.[/QUOTE]
Rookie mistake. God damn it.
Sorry, you need to Log In to post a reply to this thread.