# events

## Functions:

{% hint style="info" %}
Available cheat events can be found [here](https://docs-csgo.neverlose.cc/documentation/events).
{% endhint %}

### :set

`events.event_name:set(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>

Sets the callback for the specified event. The registered function will be called every time the specified event occurs.

### :unset

`events.event_name:unset(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</code></mark> function</td></tr></tbody></table>

Unsets the callback that was set via the <mark style="color:purple;">`:set`</mark> function from the specified event.

### :call

`events.event_name:call(...)`

<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>...</strong></td><td></td><td>Arguments to be passed by the callback</td></tr></tbody></table>

Fires the specified event.

### Alternative behavior:

### :\_\_call

`events.event_name(callback: function[, state: boolean])`

<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><tr><td><strong>state</strong></td><td><strong><code>boolean</code></strong></td><td>Optional. Callback state. If not specified then toggles the callback state for the specified function.</td></tr></tbody></table>

Sets / unsets the callback for the specified event.

{% tabs %}
{% tab title="Toggle Behavior" %}
{% code overflow="wrap" lineNumbers="true" %}

```lua
local function function_callback()
    print(globals.tickcount)
end

-- Sets the createmove callback for the specified function
events.createmove(function_callback)

-- Execute after 0.5 secs
utils.execute_after(0.5, function()
    -- Toggles the createmove callback for the specified function
    events.createmove(function_callback)
end)
```

{% endcode %}
{% endtab %}

{% tab title="State Behavior" %}
{% code overflow="wrap" lineNumbers="true" %}

```lua
local function function_callback()
    print(globals.tickcount)
end

events.createmove(function_callback, true) -- Sets the callback
events.createmove(function_callback, false) -- Unsets the callback
```

{% endcode %}
{% endtab %}
{% endtabs %}
