• Getting a variable clientside from serverside code?
    6 replies, posted
So basically I want to get a variable that I have in my serverside code into my clientside. When I'm trying to get the variable, it'll keep saying its a nil value when I can take it the same exact way in the serverside file.
usermessages.
I'm trying to send a table, and it's saying that its a table and expected a string. [code]function printCars(ply) for k,v in pairs(VEHICLE_DATABASE) do for tk, tv in pairs(v) do umsg.Start( "AddData", ply ) umsg.String(tv) umsg.End() end end end hook.Add( "PlayerInitialSpawn", "SendCarsList", printCars )[/code] I'm pretty sure the for statements above covert the table into a string, correct me if I'm wrong? And then [code]local Vehicle_Database = {}; local function AddData( data ) table.insert( Vehicle_Database, data:ReadString() ) print(data:ReadString()) end usermessage.Hook( "AddData", AddData )[/code] This is what I've gotten from the wiki, I'm assuming that I'm not doing it correctly though.
use glon to encode the table, but unless really needed, dont network tables, leads to lag.
Well I have a table that has information that I need the player to view in a menu, and I'm not quite sure what a "glon to encode the table" means. Please explain ? :D
glon.encode(yourTable) encodes a table into a string. glon.decode(string of your table) converts it back into a table.
Yea, Use glon and usermessages.
Sorry, you need to Log In to post a reply to this thread.