> Agent-readable docs index: /llms.txt. Download /docs.zip to grep all markdown files locally.

---
title: Schema Values
icon: binary
sidebar_position: 5
---

# <ApiPageIcon icon="binary" />Schema Values

<ApiExposes data="[{&#x22;k&#x22;:&#x22;OBJECT&#x22;,&#x22;c&#x22;:&#x22;method&#x22;,&#x22;s&#x22;:&#x22;value.Object&#x22;,&#x22;h&#x22;:&#x22;#valueobject&#x22;},{&#x22;k&#x22;:&#x22;OBJECT&#x22;,&#x22;c&#x22;:&#x22;method&#x22;,&#x22;s&#x22;:&#x22;value.View&#x22;,&#x22;h&#x22;:&#x22;#valueview&#x22;},{&#x22;k&#x22;:&#x22;OBJECT&#x22;,&#x22;c&#x22;:&#x22;method&#x22;,&#x22;s&#x22;:&#x22;value.AtomicCollection&#x22;,&#x22;h&#x22;:&#x22;#valueatomiccollection&#x22;},{&#x22;k&#x22;:&#x22;OBJECT&#x22;,&#x22;c&#x22;:&#x22;method&#x22;,&#x22;s&#x22;:&#x22;value.FixedArray&#x22;,&#x22;h&#x22;:&#x22;#valuefixedarray&#x22;},{&#x22;k&#x22;:&#x22;OBJECT&#x22;,&#x22;c&#x22;:&#x22;method&#x22;,&#x22;s&#x22;:&#x22;value.Named&#x22;,&#x22;h&#x22;:&#x22;#valuenamed&#x22;},{&#x22;k&#x22;:&#x22;OBJECT&#x22;,&#x22;c&#x22;:&#x22;method&#x22;,&#x22;s&#x22;:&#x22;value.DeclaredClass&#x22;,&#x22;h&#x22;:&#x22;#valuedeclaredclass&#x22;},{&#x22;k&#x22;:&#x22;OBJECT&#x22;,&#x22;c&#x22;:&#x22;method&#x22;,&#x22;s&#x22;:&#x22;value.Bitfield&#x22;,&#x22;h&#x22;:&#x22;#valuebitfield&#x22;},{&#x22;k&#x22;:&#x22;OBJECT&#x22;,&#x22;c&#x22;:&#x22;method&#x22;,&#x22;s&#x22;:&#x22;value.QuantizedVector&#x22;,&#x22;h&#x22;:&#x22;#valuequantizedvector&#x22;},{&#x22;k&#x22;:&#x22;OBJECT&#x22;,&#x22;c&#x22;:&#x22;method&#x22;,&#x22;s&#x22;:&#x22;value.QuantizedFloat&#x22;,&#x22;h&#x22;:&#x22;#valuequantizedfloat&#x22;}]" />

## value.Object<ApiTag label="object type" />

A value that is read from game memory through the schema system.

Structured schema values are views of the memory of the game. A view reads and writes the
memory directly, and it is valid only while the object that owns the memory exists.
`value.QuantizedFloat` values are copies of the data at the time of the read.

`Entity` and `value.View` have the methods below, which return the data pointer and the
schema type.

<ApiMembers>
  <ApiMember kind="method" name="value.Object:GetInstance" summary="Returns the data pointer." args="" sig="[{&#x22;s&#x22;:&#x22;value.Object:GetInstance&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;userdata&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#userdata&#x22;}]" ret="[[{&#x22;s&#x22;:&#x22;userdata&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#userdata&#x22;}]]" nodiscard>
    <ApiNotes>
      <Warning>
        This function is for advanced users. You can only use the pointer through FFI. The pointer is
        valid only while the object that owns the data exists. Do not keep it after the entity is
        deleted.
      </Warning>
    </ApiNotes>
  </ApiMember>

  <ApiMember kind="method" name="value.Object:GetSchemaType" summary="Returns the schema type." args="" sig="[{&#x22;s&#x22;:&#x22;value.Object:GetSchemaType&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;schema.Type&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/engine/schema#schematype&#x22;}]" ret="[[{&#x22;s&#x22;:&#x22;schema.Type&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/engine/schema#schematype&#x22;}]]" nodiscard />
</ApiMembers>

## value.View<ApiTag label="object type" />

<ApiSymbol inherits="[{&#x22;n&#x22;:&#x22;value.Object&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/engine/value#valueobject&#x22;}]" />

A `value.Object` that holds a pointer together with its type. Use `Cast` to read the same
address as a different `schema.Type`.

<ApiMembers>
  <ApiMember kind="method" name="value.View:Cast" summary="Returns a view of the same address with the given schema type. The type must describe the data at that address. A cast does not change the data. If `type` is **nil**, the view keeps its current type." args="type" sig="[{&#x22;s&#x22;:&#x22;value.View:Cast&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;type&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;schema.Type&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/engine/schema#schematype&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;value.View&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/engine/value#valueview&#x22;}]" ret="[[{&#x22;s&#x22;:&#x22;value.View&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/engine/value#valueview&#x22;}]]" params="[{&#x22;n&#x22;:&#x22;type&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;schema.Type&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/engine/schema#schematype&#x22;}],&#x22;d&#x22;:&#x22;The new type. It must describe the data at this address.&#x22;}]" nodiscard />
</ApiMembers>

## value.AtomicCollection<ApiTag label="object type" />

<ApiSymbol inherits="[{&#x22;n&#x22;:&#x22;{ [integer]: T }&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;{&#x22;},{&#x22;s&#x22;:&#x22; &#x22;},{&#x22;s&#x22;:&#x22;[&#x22;},{&#x22;s&#x22;:&#x22;integer&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#integer&#x22;},{&#x22;s&#x22;:&#x22;]&#x22;},{&#x22;s&#x22;:&#x22;:&#x22;},{&#x22;s&#x22;:&#x22; &#x22;},{&#x22;s&#x22;:&#x22;T&#x22;,&#x22;k&#x22;:&#x22;generic&#x22;},{&#x22;s&#x22;:&#x22; &#x22;},{&#x22;s&#x22;:&#x22;}&#x22;}]},{&#x22;n&#x22;:&#x22;value.View&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/engine/value#valueview&#x22;}]" />

A dynamic array of the engine, such as `CUtlVector`. The length operator `#` returns the
number of elements. When you index the array directly, the first element has the index `0`.
An index outside the array reads as **nil**.

`Value`, `pairs` and `ipairs` use a copy of the array in a Lua table, where the first element
has the index `1`.

<ApiMembers>
  <ApiMember kind="method" name="value.AtomicCollection:Value" summary="Copies the elements into a Lua table, where the first element has the index `1`. Entities in the collection are not copied. The table holds references to them." args="" sig="[{&#x22;s&#x22;:&#x22;value.AtomicCollection:Value&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;T&#x22;,&#x22;k&#x22;:&#x22;generic&#x22;},{&#x22;s&#x22;:&#x22;[&#x22;},{&#x22;s&#x22;:&#x22;]&#x22;}]" ret="[[{&#x22;s&#x22;:&#x22;T&#x22;,&#x22;k&#x22;:&#x22;generic&#x22;},{&#x22;s&#x22;:&#x22;[&#x22;},{&#x22;s&#x22;:&#x22;]&#x22;}]]" nodiscard />
</ApiMembers>

## value.FixedArray<ApiTag label="object type" />

<ApiSymbol inherits="[{&#x22;n&#x22;:&#x22;{ [integer]: T }&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;{&#x22;},{&#x22;s&#x22;:&#x22; &#x22;},{&#x22;s&#x22;:&#x22;[&#x22;},{&#x22;s&#x22;:&#x22;integer&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#integer&#x22;},{&#x22;s&#x22;:&#x22;]&#x22;},{&#x22;s&#x22;:&#x22;:&#x22;},{&#x22;s&#x22;:&#x22; &#x22;},{&#x22;s&#x22;:&#x22;T&#x22;,&#x22;k&#x22;:&#x22;generic&#x22;},{&#x22;s&#x22;:&#x22; &#x22;},{&#x22;s&#x22;:&#x22;}&#x22;}]},{&#x22;n&#x22;:&#x22;value.View&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/engine/value#valueview&#x22;}]" />

A fixed size array of the engine, such as `uint32[2]`. The length operator `#` returns the
number of elements. When you index the array directly, the first element has the index `0`.
An index outside the array reads as **nil**.

`Value`, `pairs` and `ipairs` use a copy of the array in a Lua table, where the first element
has the index `1`.

<ApiMembers>
  <ApiMember kind="method" name="value.FixedArray:Value" summary="Copies the elements into a Lua table, where the first element has the index `1`." args="" sig="[{&#x22;s&#x22;:&#x22;value.FixedArray:Value&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;T&#x22;,&#x22;k&#x22;:&#x22;generic&#x22;},{&#x22;s&#x22;:&#x22;[&#x22;},{&#x22;s&#x22;:&#x22;]&#x22;}]" ret="[[{&#x22;s&#x22;:&#x22;T&#x22;,&#x22;k&#x22;:&#x22;generic&#x22;},{&#x22;s&#x22;:&#x22;[&#x22;},{&#x22;s&#x22;:&#x22;]&#x22;}]]" nodiscard />
</ApiMembers>

## value.Named<ApiTag label="object type" />

Adds the `GetClassName` method to values whose schema type is a declared class of the engine.

<ApiMembers>
  <ApiMember kind="method" name="value.Named:GetClassName" summary="Returns the name of the class." args="" sig="[{&#x22;s&#x22;:&#x22;value.Named:GetClassName&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;string&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#string&#x22;}]" ret="[[{&#x22;s&#x22;:&#x22;string&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#string&#x22;}]]" nodiscard />
</ApiMembers>

## value.DeclaredClass<ApiTag label="object type" />

<ApiSymbol inherits="[{&#x22;n&#x22;:&#x22;value.Named&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/engine/value#valuenamed&#x22;},{&#x22;n&#x22;:&#x22;value.View&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/engine/value#valueview&#x22;}]" />

An object of a declared class of the engine. Read and write its schema fields by name with
`self.<name>`.

<ApiMembers>
  <ApiMember kind="method" name="value.DeclaredClass:GetField" summary="Reads a schema field by name. This does the same as `self.<name>`. Use it when the name of the field is held in a variable, or when the field has the same name as a method." args="name" sig="[{&#x22;s&#x22;:&#x22;value.DeclaredClass:GetField&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;name&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;string&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#string&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;any&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;}]" ret="[[{&#x22;s&#x22;:&#x22;any&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;}]]" params="[{&#x22;n&#x22;:&#x22;name&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;string&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#string&#x22;}],&#x22;d&#x22;:&#x22;The name of the schema field.&#x22;}]" nodiscard />

  <ApiMember kind="method" name="value.DeclaredClass:SetField" summary="Writes a schema field by name. This does the same as `self.<name> = value`." args="name, value" sig="[{&#x22;s&#x22;:&#x22;value.DeclaredClass:SetField&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;name&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;string&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#string&#x22;},{&#x22;s&#x22;:&#x22;, &#x22;},{&#x22;s&#x22;:&#x22;value&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;any&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;}]" params="[{&#x22;n&#x22;:&#x22;name&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;string&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#string&#x22;}],&#x22;d&#x22;:&#x22;The name of the schema field.&#x22;},{&#x22;n&#x22;:&#x22;value&#x22;,&#x22;t&#x22;:[{&#x22;s&#x22;:&#x22;any&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;}],&#x22;d&#x22;:&#x22;The value to write. It is converted to the schema type of the field.&#x22;}]">
    <ApiNotes>
      It takes the same values as a field assignment. Throws an error if the field has a type that
      cannot be written, such as a bitfield or a fixed array.
    </ApiNotes>
  </ApiMember>
</ApiMembers>

## value.Bitfield<ApiTag label="object type" />

<ApiSymbol inherits="[{&#x22;n&#x22;:&#x22;value.View&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/engine/value#valueview&#x22;}]" />

A packed integer field that uses fewer bits than its storage type. You cannot get its value
through the schema. Reading the field returns this object, and writing the field throws an
error.

<ApiMembers>
  <ApiMember kind="method" name="value.Bitfield:NumBits" summary="Returns the number of bits in the field." args="" sig="[{&#x22;s&#x22;:&#x22;value.Bitfield:NumBits&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;integer&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#integer&#x22;}]" ret="[[{&#x22;s&#x22;:&#x22;integer&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#integer&#x22;}]]" nodiscard />
</ApiMembers>

## value.QuantizedVector<ApiTag label="object type" />

<ApiSymbol inherits="[{&#x22;n&#x22;:&#x22;value.DeclaredClass&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/engine/value#valuedeclaredclass&#x22;}]" />

An object of a quantized vector class, such as `CNetworkOriginQuantizedVector`.

<ApiMembers>
  <ApiMember kind="method" name="value.QuantizedVector:Get" summary="Returns the quantized vector as a regular 3D `Vector`." args="" sig="[{&#x22;s&#x22;:&#x22;value.QuantizedVector:Get&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;Vector&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector#vector-1&#x22;}]" ret="[[{&#x22;s&#x22;:&#x22;Vector&#x22;,&#x22;k&#x22;:&#x22;class&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/mathlib/vector#vector-1&#x22;}]]" nodiscard />
</ApiMembers>

## value.QuantizedFloat<ApiTag label="object type" />

A copy of one component of a quantized vector. The copy does not change when the game
changes the field. Read the field again to get the current value.

<ApiMembers>
  <ApiMember kind="method" name="value.QuantizedFloat:MinValue" summary="Returns the lowest value that the real value can have." args="" sig="[{&#x22;s&#x22;:&#x22;value.QuantizedFloat:MinValue&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;number&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#number&#x22;}]" ret="[[{&#x22;s&#x22;:&#x22;number&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#number&#x22;}]]" nodiscard />

  <ApiMember kind="method" name="value.QuantizedFloat:MaxValue" summary="Returns the highest value that the real value can have." args="" sig="[{&#x22;s&#x22;:&#x22;value.QuantizedFloat:MaxValue&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;number&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#number&#x22;}]" ret="[[{&#x22;s&#x22;:&#x22;number&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#number&#x22;}]]" nodiscard />

  <ApiMember kind="method" name="value.QuantizedFloat:Get" summary="Returns the value." args="" sig="[{&#x22;s&#x22;:&#x22;value.QuantizedFloat:Get&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;number&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#number&#x22;}]" ret="[[{&#x22;s&#x22;:&#x22;number&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#number&#x22;}]]" nodiscard />

  <ApiMember kind="method" name="value.QuantizedFloat:NumBits" summary="Returns the number of bits that the value uses." args="" sig="[{&#x22;s&#x22;:&#x22;value.QuantizedFloat:NumBits&#x22;},{&#x22;s&#x22;:&#x22;(&#x22;},{&#x22;s&#x22;:&#x22;)&#x22;},{&#x22;s&#x22;:&#x22;: &#x22;},{&#x22;s&#x22;:&#x22;integer&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#integer&#x22;}]" ret="[[{&#x22;s&#x22;:&#x22;integer&#x22;,&#x22;k&#x22;:&#x22;prim&#x22;,&#x22;h&#x22;:&#x22;/cs2/api_reference/lua/base#integer&#x22;}]]" nodiscard />
</ApiMembers>
