# cvar

### Example

```lua
cvar.mp_teammates_are_enemies:int(1)
cvar.clear:call()
```

## Functions:

### :call

`cvar_object:call(...)`

<table><thead><tr><th width="150">Name</th><th width="150">Type</th><th width="395.7341676883734">Description</th></tr></thead><tbody><tr><td>...</td><td></td><td>Arguments passed to the callback</td></tr></tbody></table>

Executes a ConCommand or cvar callback, passing its arguments to it.

### :int

{% tabs %}
{% tab title="Get value" %}
`cvar_object:int():` <mark style="color:purple;">`number`</mark>
{% endtab %}

{% tab title="Set value" %}
`cvar_object:int(value: number[, raw: boolean ])`

<table><thead><tr><th width="150">Name</th><th width="150">Type</th><th width="395.7341676883734">Description</th></tr></thead><tbody><tr><td><strong>value</strong></td><td><strong><code>number</code></strong></td><td>New int value</td></tr><tr><td><strong>raw</strong></td><td><strong><code>boolean</code></strong></td><td>Optional. If <mark style="color:purple;"><code>true</code></mark> then the <code>raw</code> value will be set</td></tr></tbody></table>
{% endtab %}
{% endtabs %}

Gets or sets the ConVar int value.

### :float

{% tabs %}
{% tab title="Get value" %}
`cvar_object:float():` <mark style="color:purple;">`number`</mark>
{% endtab %}

{% tab title="Set value" %}
`cvar_object:float(value: number[, raw: boolean ])`

<table><thead><tr><th width="150">Name</th><th width="150">Type</th><th width="395.7341676883734">Description</th></tr></thead><tbody><tr><td><strong>value</strong></td><td><strong><code>number</code></strong></td><td>New float value</td></tr><tr><td><strong>raw</strong></td><td><strong><code>boolean</code></strong></td><td>Optional. If <mark style="color:purple;"><code>true</code></mark> then the <code>raw</code> value will be set</td></tr></tbody></table>
{% endtab %}
{% endtabs %}

Gets or sets the ConVar float value.

### :string

`cvar_object:string([ value: any ]):` <mark style="color:purple;">`string`</mark>

<table><thead><tr><th width="150">Name</th><th width="150">Type</th><th width="395.7341676883734">Description</th></tr></thead><tbody><tr><td><strong>value</strong></td><td><strong><code>any</code></strong></td><td>New string value. If not specified then returns the string value of the ConVar</td></tr></tbody></table>

Gets or sets the ConVar string value.

### :set\_callback

{% tabs %}
{% tab title="ConVar" %}
You can access the `cvar_object`, `old_value` and `new_value` by adding them to the function arguments.
{% endtab %}

{% tab title="Command" %}
You can access the `cvar_object` and `args` by adding them to the function arguments. Inside the callback, return false to prevent the command from being executed.
{% endtab %}
{% endtabs %}

`cvar_object:set_callback(callback: function)`

<table><thead><tr><th width="150">Name</th><th width="162.52330706200414">Type</th><th width="410.3276962436035">Description</th></tr></thead><tbody><tr><td><strong>callback</strong></td><td><strong><code>function</code></strong></td><td>Lua function to call</td></tr></tbody></table>

Registers the callback to the specified ConVar/Command. The registered function will be called every time the specified convar value is updated.

### :unset\_callback

`cvar_object:unset_callback(callback: function)`

<table><thead><tr><th width="150">Name</th><th width="162.52330706200414">Type</th><th width="410.3276962436035">Description</th></tr></thead><tbody><tr><td><strong>callback</strong></td><td><strong><code>function</code></strong></td><td>Lua function that was passed to the <mark style="color:purple;"><code>:set_callback</code></mark> function</td></tr></tbody></table>

Unregisters the callback that was set via the <mark style="color:purple;">`:set_callback`</mark> function from the specified ConVar/Command.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs-csgo.neverlose.cc/documentation/variables/cvar.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
