Basically i'm attempting to read information being sent from server side so I can display it client side. Since i'm pulling the information from a directory in the data folder that has all of the players data tables stored in them server side I have to send the tables client side to get their information to display. But for some reason what i'm trying isn't working and i'm stumped.
Client side:
local tbl = {}
for i=1,tonumber(net.ReadString()) do
tbl[i] = net.ReadTable()
print(util.TableToJSON(tbl[i].steam64))
end
Server side:
net.WriteString(table.Count(file.Find("test_folder/players/*.txt","DATA")))
for k,v in pairs(file.Find("test_folder/players/*.txt","DATA")) do
net.WriteTable(util.JSONToTable(file.Read("test_folder/players/"..v)))
end
When the for loop is ran client side it prints nothing with no errors. Imgur
Yes the tables are being sent to client side and are read and saved to a table variable. To answer your question about writing a number as a string, I know it's not correct, but it works.
Start, Send, Receive (as your code doesnt have them)
There is no needs to send table count (if you are sending table, ofc) especially as string.
I've updated my post to show a little more detail into my script. I'm sending the table count client side because the for loop is going to input the steam64 value from each table sent into a dlistview.
I've updated my post, example:
local fileData = file.Read("test_folder/players/"..v) -- LOL, just realised that second argument is missing ("DATA")
local tbl = util.JSONToTable(fileData)
net.WriteTable(tbl)
Its still printing blank with no errors. I've checked to see if the client side is receiving the tables and it is:
(Converted to json to give you a view of its structure):
[{"steam64":"76561198058323018","name":"Test Name2","model":"models/player/combine_super_soldier.mdl"}]
[{"steam64":"76561198058323018","name":"Test Name","model":"models/player/gman_high.mdl"}]
Maybe you are sending a lot of data (limit is 65533 bytes), check your server console for warnings
There are no warnings printed in the server console.
Yes, i'm referencing the steam64 value from the table example I gave. Its printing a blank value, not nil, nor giving an error so i'm not sure whats going on.
Yes, that's just because I want to see if it prints anything, which it doesn't.
util.TableToJSON converts the table value to a string so I can print it. When I use AddLine it automatically gets the value without me having to convert it.
Ah your right, i'm not sure what I was thinking. It now prints nill.
Just judging on that output it looks like your tables are contained in other tables.
Try
print(v[1].steam64)
Thanks that fixed it!
Sorry, you need to Log In to post a reply to this thread.