Too large for umsg

I’m trying to send a table (from a file) to the client with a umsg, but the table is too large:



Warning: Usermessage was larger than 256 bytes. This will cause problems.
Error sending usermessage! Too Large!


I tried using datastreams, but the clientside hook didn’t get called.
Here’s the code I’m using:
[lua]
require(“glon”)
if not(file.Exists(ply.FilePath)) then
Info = {–[[Blah blah, a table.]]}
ply.Info = glon.encode(Info)
file.Write(ply.FilePath, glon.encode(Info))
else
ply.Info = file.Read(ply.FilePath)
end
umsg.Start(“PlyInfo”, ply)
umsg.String(ply.Info)
umsg.End()
[/lua]

And on the client:
[lua]
require(“glon”)
function ReadInfo(um)
LocalPlayer().Info = glon.decode(um:ReadString())
end
usermessage.Hook(“PlyInfo”, ReadInfo)
[/lua]

When I tried to switch to datastreams, I used:
[lua]
datastream.StreamToClients(ply, “PlyInfo”, Info)
[/lua]

And:
[lua]
function ReadInfo(handler, id, encoded, decoded)
LocalPlayer().Info = decoded
end
datastream.Hook(“PlyInfo”, ReadInfo)
[/lua]

Can anyone help?

There is a hook to allow datastream to work. (AcceptInput)

You mean **[Gamemode.AcceptStream

http://wiki.garrysmod.com/favicon.ico](wiki.garrysmod.com/?title=Gamemode.AcceptStream)**?
It says that’s for sending from client to server, but I’m sending from server to client.
If that’s not what you meant, can you link me to it?

That is the hook I meant :saddowns:

Bumping.

datastream.StreamToClients(ply, “PlyInfo”, ply.Info)
i think thats what your missing.

ply.Info = glon.encode(Info)

Info is already defined. (meant to be unglon-encoded when sent to datastream)

Can OP show us your code with datastream?

On server:
[lua]
require(“glon”)
if not(file.Exists(ply.FilePath)) then
Info = {–[[Blah blah, a table.]]}
ply.Info = Info
file.Write(ply.FilePath, glon.encode(Info))
else
ply.Info = glon.decode(file.Read(ply.FilePath))
end
datastream.StreamToClients(ply, “PlyInfo”, ply.Info)
[/lua]

On client:
[lua]
function ReadInfo(handler, id, raw, decoded)
LocalPlayer().Info = decoded
print(“Testing”)
PrintTable(decoded)
end
datastream.Hook(“PlyInfo”, ReadInfo)
[/lua]

Could try this.

http://www.facepunch.com/showthread.php?t=980338

Worked perfect, thanks.