I'm trying to send a table (from a file) to the client with a umsg, but the table is too large:
[code]
Warning: Usermessage was larger than 256 bytes. This will cause problems.
Error sending usermessage! Too Large!
[/code]
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?
You mean [b][url=wiki.garrysmod.com/?title=Gamemode.AcceptStream]Gamemode.AcceptStream [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]?
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?
Bumping.
datastream.StreamToClients(ply, "PlyInfo", ply.Info)
i think thats what your missing.
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.
[url]http://www.facepunch.com/showthread.php?t=980338[/url]
Worked perfect, thanks.
Sorry, you need to Log In to post a reply to this thread.