Best way to send data from client to server

What is the best way to send data from Client to Server?
I don’t want to have to use Console commands, and I know that usermessages are only from server to client.


Usermessages can’t send tables correct?

What kind of data? If you’re sending massive tables of stuff then it’s probably best to use datastream. An alternate way that I experimented with is you can use GLON to encode a table, use that as an argument to a concommand, and then decode the argument serverside.

A table with no more then 10 entity entries, can it be sent with a Usermessage?

no, seeing as you want client->server

Usermessages are for server to client communications. Datastream passes from the client to the server.

Here’s an example:

local t = table.concat(args," ")
local status,err = pcall(function() t = glon.decode(t) end)
if not status then error(“Table not formatted correctly!”) end

LocalPlayer():ConCommand("print_glon " … glon.encode({“a table”,“of things”,5,Vector(3,2,1)}))[/lua]