Revision Difference
net.WriteVector#567661
<function name="WriteVector" parent="net" type="libraryfunc">
<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.
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 1 digit (5 bits).
</description>
<realm>Shared</realm>
<args>
<arg name="vector" type="Vector">The vector to be sent.</arg>
</args>
</function>
<example>
<description>Create a server-side command to send a vector to all clients, and a function to receive the vector on the client-side. This example displays the vector compression discussed above.</description>
<code>
if SERVER then
util.AddNetworkString( "testingvecs" )
concommand.Add( "dovectest", function()
net.Start( "testingvecs" )
net.WriteVector( Vector( 10000, 20000, -20000.123456789 ) )
net.Broadcast()
end )
elseif CLIENT then
net.Receive( "testingvecs", function( len )
print( "RECV: vec = " .. tostring( net.ReadVector() ) .. "\n" )
end )
end
</code>
<output>
```
RECV: vec = 10000.000000 3616.000000 -3616.093750
```
</output>
</example>
Garry's Mod
Rust
Steamworks
Wiki Help