SendLua() giving "malformed number"

I need to send a vector through ply:SendLua(), doing that returns only a number on the client for some reason and trying to send separate pieces of the vector as a table gives “[LuaCmd:1] malformed number near ‘426C76A0’
n” error. Here’s the code:

ply:SendLua("LocalPlayer().VC_TPTSP = "..tostring({Vec.x, Vec.y, Vec.z}))

if ply.VC_TPTSP then PrintTable(ply.VC_TPTSP) else print("Nil") end

//gives the number malformed error

So how should I send a vector through SendLua()?

tostring( {Vec.x, Vec.y, Vec.z} ) returns “table: XXXXXXX”, so that won’t work. Use usermessages.

– Server
umsg.Start( “SendVector”, ply )
umsg.Vector( Vec )

– Client
usermessage.Hook( “SendVector”, function( um )
LocalPlayer().VC_TPTSP = um:Vector()
end )

[editline]23rd January 2011[/editline]

Or if you really insist on using SendLua:

[lua]ply:SendLua( “LocalPlayer().VC_TPTSP = Vector( “…Vec.x…”,”…Vec.y…","…Vec.z…")" )[/lua]

Don’t need to use UserMessages, since its only going to be sent about every 5 minutes. Thanks.

That is no reason not to use usermessages.

Use them. SendLua still uses usermessages internally, you’re just wasting bandwidth sending them.

Alright, I’ll use them.