Garry's Mod Wiki

net.WriteVector

net.WriteVector( Vector vector )

Description

Appends a vector to the current net message. Vectors sent by this function are compressed, which may result in precision loss. XYZ components greater than 16384 or less than -16384 are irrecoverably altered (most significant bits are trimmed) and precision after the decimal point is low.

Arguments

1 Vector vector
The vector to be sent.

Example

Create a serverside command to send a vector to all clients, and a function to receive the vector on the clientside. This example displays the vector compression discussed above.

if SERVER then util.AddNetworkString("testingvecs") function testvecs_sv() net.Start("testingvecs") net.WriteVector(Vector(10000, 20000, -20000.123456789)) net.Broadcast() end concommand.Add("dovectest", testvecs_sv) elseif CLIENT then function testvecs_cl(len) print("RECV: vec = " .. tostring(net.ReadVector()) .. "\n") end net.Receive("testingvecs", testvecs_cl) end
Output: RECV: vec = 10000.000000 3616.000000 -3616.093750

Page Links


Special Pages


Wikis

?

Render Time: 32ms

Session 0
DB GetPage 6
Generate Html 3
SaveChanges 8
Render Body 0
Render Sidebar 13