Squirrel Variable Byte Format Documentation

Server to Client Byte Format

Null

Byte Format: o

Byte 1
o

Integer (Example: 15)

Byte 1Byte 2Byte 3Byte 4Byte 5
i0f000000

Float (Example: 3.14)

Byte 1Byte 2Byte 3Byte 4Byte 5
fc3f54840

Boolean (Example: true)

Byte 1Byte 2
b01

String (Example: "apple")

Byte 1Byte 2Byte 3Byte 4Byte 5Byte 6Byte 7Byte 8
s00056170706c65
s..apple

Vector (Example: (1.0, 2.0, 3.0))

Byte 1Bytes 2-5Bytes 6-9Bytes 10-13
v00 00 80 3f00 00 00 4000 00 40 40

Quaternion (Example: (1.0, 2.0, 3.0, 4.0))

Byte 1Byte 2-5Byte 6-9Byte 10-13Byte 14-17
q00 00 80 3f00 00 00 4000 00 40 4000 00 80 40

Array (Example: [100, 200])

Byte 1Bytes 2-5 (L)Byte 6-10Byte 11-15
a0a 00 00 0069 64 00 00 0069 c8 00 00 00

Table (Example: {a=1, b="okay"})

Byte 1Bytes 2-5 (L)Key 1Value 1Key 2Value 2
t14 00 00 0073 00 01 6169 01 00 00 0073 00 01 6273 00 04 6f 6b 61 79

GetRemoteValue (Example: GetRemoteValue("a"))

Byte 1Bytes 2-5 (L)Key
g04 00 00 0073 00 01 61

GetRemoteValueEx (Example: GetRemoteValueEx("Console", "Print"))

Byte 1Bytes 2-5 (L)ObjectKey
k17 00 00 0067 0a 00 00 00 73 00 07 43 6f 6e 73 6f 6c 6573 00 05 50 72 69 6e 74

SetRemoteValue (Example: SetRemoteValue("a", 1.0))

Byte 1Bytes 2-5 (L)KeyValue
h09 00 00 0073 00 01 6166 00 00 80 3f

SetRemoteValueEx (Example: below)

Format: First byte = 'j' (0x6B), followed by L (total byte length of the object, key, and value encodings). The object, key, and value are encoded sequentially according to their types.

Example

Example: Creating and modifying a vector's component on the client side.

Step 1: Creating a Vector on the Client

Command: RemoteExec(SetRemoteValue("a", Vector(1,2,3)), FindPlayer(0))

This will create a vector with coordinates (1, 2, 3) on the client side.

Step 2: Modifying the Y Component of the Vector

Command: RemoteExec(SetRemoteValueEx(GetRemoteValue("a"), "Y", 5), FindPlayer(0))

This updates the Y component of the vector to 5 on the client side.

Byte 1Bytes 2-5 (L)ObjectKeyValue
j 11 00 00 00 67 0a 00 00 00 73 00 01 61 73 00 01 59 69 05 00 00 00

CallRemoteFunc (Example: CallRemoteFunc(GetRemoteValue("rprint"), "Hello"))

Byte 1Bytes 2-5 (L)FunctionParameter 1
F16 00 00 0067 09 00 00 00 73 00 06 72 70 72 69 6e 7473 00 05 48 65 6c 6c 6f

CallRemoteFuncEx (No example provided)

Format: First byte = 'E', followed by L, function, environment, and arguments encoded in sequence.

Metamethods for Userdata/Superblob

_add (Addition)

This metamethod allows addition between an object and another operand.

Example: GetRemoteValue("a") + 5
Byte 1Bytes 2-5 (L)ObjectOperand
+ 0e 00 00 00 67 04 00 00 00 73 00 01 61 69 05 00 00 00

_sub (Subtraction)

This metamethod allows subtraction between an object and another operand.

Example: GetRemoteValue("a") - 5
Byte 1Bytes 2-5 (L)ObjectOperand
- 0e 00 00 00 67 04 00 00 00 73 00 01 61 69 05 00 00 00

_mul (Multiplication)

This metamethod allows multiplication between an object and another operand.

Example: GetRemoteValue("a") * 5
Byte 1Bytes 2-5 (L)ObjectOperand
* 0e 00 00 00 67 04 00 00 00 73 00 01 61 69 05 00 00 00

_div (Division)

This metamethod allows division of an object by another operand.

Example: GetRemoteValue("a") / 5
Byte 1Bytes 2-5 (L)ObjectOperand
/ 0e 00 00 00 67 04 00 00 00 73 00 01 61 69 05 00 00 00

_modulo (Modulo)

This metamethod calculates the remainder of the division of an object by another operand.

Example: GetRemoteValue("a") % 5
Byte 1Bytes 2-5 (L)ObjectOperand
% 0e 00 00 00 67 04 00 00 00 73 00 01 61 69 05 00 00 00

_unm (Unary Minus)

This metamethod changes the sign of the object.

Example: -GetRemoteValue("a")
Byte 1Bytes 2-5 (L)Object
u 09 00 00 00 67 04 00 00 00 73 00 01 61