Hello everyone,
I'm having an issue while i'm creating my addon. My problem is the next one, I would like to pick somes infos from a table : steam id, unban date, how much left to be unban and the admin's name . Here is my code :
[CODE]--client
net.Receive("sendtable", function()
local len = net.ReadUInt( 32 )
local json = net.ReadData( len ) -- lis les donnees
json = util.Decompress(json) -- decompress
ULib.bans = util.JSONToTable (json) -- transforme en tableau
PrintTable(ULib.bans)
end)
--serveur
util.AddNetworkString( "sendtable" )
local json = util.TableToJSON(ULib.bans)
json = util.Compress(json) -- compresser
net.Start( "sendtable" )
net.WriteUInt( json:len(), 32 )
net.WriteData( json, json:len() )
net.Broadcast()
[/CODE]
The problem is that when I use print table, it gives me that
[CODE]"STEAM_1:0:142064608"
{
"unban" "0"
"time" "1534592703"
"admin" "yung pitch(STEAM_0:0:142066608)"
}
[/CODE]
while I would like to get the infos without "" and {}. Moreover if you know how to add a line to a Dlistpanel for every steam id it could be cool.
Regards,
PrintTable exists to turn tables into readable (and printable) strings. Right before that call you do ULib.bans = util.JSONToTable(json) which converts the json table to a Lua table. THAT is what you should be doing operations on, as it will let you access the data directly.
I would prefer if you want to do a ban system you should use jsontotable and make file.Write to store the entries first than like Socram says util.JSONToTable(json) to convert it as a lua table and then u dont have the "" anymore.. or think about sqlite storage..
Sorry, you need to Log In to post a reply to this thread.