> For the complete documentation index, see [llms.txt](https://lua2.fatality.win/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lua2.fatality.win/api/instances/events.md).

# events

<table><thead><tr><th width="261">Usage: events.{event_name}</th></tr></thead><tbody><tr><td></td></tr></tbody></table>

There are a number of events that Fatality provides to use in the API - from various hooks, to in-game events. Each event entry is an object of [`Event_t`](/api/instances/events/event_t.md). This table documents events to be used by your scripts.

{% hint style="info" %}
You are not required to remove events when your script unloads. It is done automatically by the API engine.
{% endhint %}

{% hint style="info" %}
There is an equivalent to an unload or shutdown callback, check it out [here](/api/global-functions.md#error-3).
{% endhint %}

## presentQueue

<mark style="color:green;">**`Field`**</mark>

Invoked each time the game queues a frame for rendering. This is the only permitted location for drawing on screen.

**Arguments**

None.

***

## frameStageNotify

<mark style="color:green;">**`Field`**</mark>

Invoked every time the game progresses onto another frame stage. This event is called before the game handles a new frame stage.

**Arguments**

| Name    | Type                                                     | Description          |
| ------- | -------------------------------------------------------- | -------------------- |
| `stage` | [`ClientFrameStage_t`](/api/enums/clientframestage_t.md) | Current frame stage. |

***

## renderStartPre

<mark style="color:green;">**`Field`**</mark>

Invoked every time game starts the scene rendering process. This event is called before the game's function runs.

**Arguments**

None.

***

## renderStartPost

<mark style="color:green;">**`Field`**</mark>

Invoked every time game starts scene rendering process. This event is called after the game's function runs.

**Arguments**

| Name    | Type                                     | Description             |
| ------- | ---------------------------------------- | ----------------------- |
| `setup` | [`CViewSetup`](/api/types/cviewsetup.md) | View setup information. |

***

## setupViewPre

<mark style="color:green;">**`Field`**</mark>

Invoked every time the game sets up the view information. This event is called after the game's function runs.

{% hint style="info" %}
You can retrieve the view information from `game.viewRender` service.
{% endhint %}

**Arguments**

None.

***

## overrideView

<mark style="color:green;">**`Field`**</mark>

Invoked every time the game internally overrides view information. You are free to change whatever you like in the provided view setup.

**Arguments**

| Name    | Type                                     | Description             |
| ------- | ---------------------------------------- | ----------------------- |
| `setup` | [`CViewSetup`](/api/types/cviewsetup.md) | View setup information. |

***

## createMove

<mark style="color:green;">**`Field`**</mark>

Invoked every time the game processes a game tick.

**Arguments**

| Name          | Type                                 | Description              |
| ------------- | ------------------------------------ | ------------------------ |
| `userCommand` | [`CUserCmd`](/api/types/cusercmd.md) | Create move information. |

***

## event﻿ <a href="#event" id="event"></a>

<mark style="color:green;">**`Field`**</mark>

Invoked every time a game event fires.

{% hint style="info" %}
We do not listen to every single event that exists in the game. If you need something that we don't listen to, please use [`mods.events`](/api/instances/mods.md#events)
{% endhint %}

**Arguments**

| Name    | Type                                       | Description |
| ------- | ------------------------------------------ | ----------- |
| `event` | [`GameEvent_t`](/api/types/gameevent_t.md) | Game event. |

***

## input﻿ <a href="#input" id="input"></a>

<mark style="color:green;">**`Field`**</mark>

Invoked every time the GUI processes input.

**Arguments**

| Name  | Type | Description                                                                                                                                       |
| ----- | ---- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `msg` | int  | System message. [Documentation](https://learn.microsoft.com/en-us/windows/win32/winmsg/about-messages-and-message-queues#system-defined-messages) |
| `w`   | int  | WPARAM.                                                                                                                                           |
| `l`   | int  | LPARAM.                                                                                                                                           |

***

## menuToggled <a href="#input" id="input"></a>

<mark style="color:green;">**`Field`**</mark>

Invoked every time the GUI window is opened or closed.

**Arguments**

| Name      | Type      | Description                         |
| --------- | --------- | ----------------------------------- |
| `visible` | `boolean` | Whether or not the menu is visible. |

***

## playerInfoPre <a href="#input" id="input"></a>

<mark style="color:green;">**`Field`**</mark>

Invoked every time **before** the player ESP is rendered. Useful for accessing the rendering layer for visuals or adding new elements to ESP.

{% hint style="info" %}
This doesn't override the software's configuration, meaning that if you have `ESP` disabled for either enemies or teammates, the callback will not be called for those players.
{% endhint %}

**Arguments**

| Name   | Type                                                             | Description         |
| ------ | ---------------------------------------------------------------- | ------------------- |
| `data` | [`PlayerInfoCallbackData`](/api/types/playerinfocallbackdata.md) | The player ESP data |

***

## playerInfoPost <a href="#input" id="input"></a>

<mark style="color:green;">**`Field`**</mark>

Invoked every time **after** the player ESP is rendered.

{% hint style="info" %}
This doesn't override the software's configuration, meaning that if you have `ESP` disabled for either enemies or teammates, the callback will not be called for those players.
{% endhint %}

**Arguments**

| Name   | Type                                                             | Description         |
| ------ | ---------------------------------------------------------------- | ------------------- |
| `data` | [`PlayerInfoCallbackData`](/api/types/playerinfocallbackdata.md) | The player ESP data |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://lua2.fatality.win/api/instances/events.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
