# client

### Functions:

#### client.camera\_angles

`client.camera_angles([pitch: number, yaw: number])`

| Argument  | Type                | Description |
| --------- | ------------------- | ----------- |
| **pitch** | number (-90 - 90)   | Pitch       |
| **yaw**   | number (-180 - 180) | Yaw         |

Get or set camera angles

#### client.camera\_position

`client.camera_position()`: number, number, number

Returns x, y, z world coordinates of the game's camera position, or nil on failure.

#### client.color\_log

`client.color_log(r: number, g: number, b: number, msg: string[, ...])`

| Argument | Type   | Description                                        |
| -------- | ------ | -------------------------------------------------- |
| **r**    | number | Red (0-255)                                        |
| **g**    | number | Green (0-255)                                      |
| **b**    | number | Blue (0-255)                                       |
| **msg**  | string | The message                                        |
| **...**  |        | Comma-separated arguments to concatenate with msg. |

Logs a colored message to console. End the string with \0 to prevent it from adding a newline.

#### client.create\_interface

`client.create_interface(module_name: string, interface_name: string)`: userdata (ffi pointer)

| Argument            | Type   | Description                                        |
| ------------------- | ------ | -------------------------------------------------- |
| **module\_name**    | string | Filename of the module that contains the interface |
| **interface\_name** | string | Name of the interface                              |

Returns a pointer to the interface, or nil on failure.

#### client.delay\_call

`client.delay_call(delay: number, callback: function[, ...])`

| Argument     | Type     | Description                                               |
| ------------ | -------- | --------------------------------------------------------- |
| **delay**    | number   | Time in seconds to wait before calling callback.          |
| **callback** | function | The lua function that will be called after delay seconds. |
| **...**      |          | Arguments that will be passed to the callback.            |

Executes the callback after delay seconds, passing the arguments to it.

#### client.draw\_debug\_text

`client.draw_debug_text(x: number, y: number, z: number, line_offset: number, duration: number, r: number, g: number, b: number, a: number, ...)`

| Argument         | Type                      | Description                                              |
| ---------------- | ------------------------- | -------------------------------------------------------- |
| **x**            | number (world coordinate) | Position in world space                                  |
| **y**            | number (world coordinate) | Position in world space                                  |
| **z**            | number (world coordinate) | Position in world space                                  |
| **line\_offset** | number                    | Used for vertical alignment, use 0 for the first line.   |
| **duration**     | number                    | Time in seconds that the text will remain on the screen. |
| **r**            | number                    | Red (0-255)                                              |
| **g**            | number                    | Green (0-255)                                            |
| **b**            | number                    | Blue (0-255)                                             |
| **a**            | number                    | Alpha (0-255)                                            |
| **...**          |                           | The text that will be drawn                              |

Avoid calling this during the paint event.

#### client.draw\_hitboxes

`client.draw_hitboxes(entindex: number, duration: number, hitboxes: number, r: number, g: number, b: number, a: number[, tick: number])`

| Argument     | Type               | Description                                                                 |
| ------------ | ------------------ | --------------------------------------------------------------------------- |
| **entindex** | number (entindex)  | Entity index                                                                |
| **duration** | number             | Time in seconds                                                             |
| **hitboxes** | number (hitbox id) | Either the hitbox index, an array of hitbox indices, or 19 for all hitboxes |
| **r**        | number             | Red (0-255)                                                                 |
| **g**        | number             | Green (0-255)                                                               |
| **b**        | number             | Blue (0-255)                                                                |
| **a**        | number             | Alpha (0-255)                                                               |
| **tick**     | number             | Integer                                                                     |

Draws hitbox overlays. Avoid calling this during the paint event.

#### client.error\_log

`client.error_log(msg: string)`

| Argument | Type   | Description       |
| -------- | ------ | ----------------- |
| **msg**  | string | The error message |

General game- and cheat-related functions

#### client.exec

`client.exec(cmd: string[, ...])`

| Argument | Type   | Description                                        |
| -------- | ------ | -------------------------------------------------- |
| **cmd**  | string | The console command(s) to execute.                 |
| **...**  |        | Comma-separated arguments to concatenate with cmd. |

Executes a console command. Multiple commands can be combined with ';'. Be careful when passing user input (including usernames) to it.

#### client.eye\_position

`client.eye_position()`: number, number, number

Returns x, y, z world coordinates of the local player's eye position, or nil on failure.

#### client.find\_signature

`client.find_signature(module_name: string, pattern: string)`: userdata (ffi pointer)

| Argument         | Type   | Description                                                          |
| ---------------- | ------ | -------------------------------------------------------------------- |
| **module\_name** | string | Filename of the module that contains the interface                   |
| **pattern**      | string | String of the signature. Escape with \x, replace wildcards with \xCC |

Finds the specified pattern and returns a pointer to it, or nil if not found.

#### client.get\_model\_name

`client.get_model_name(model_index: number)`: string

| Argument         | Type                 | Description |
| ---------------- | -------------------- | ----------- |
| **model\_index** | number (model index) | Model index |

Returns model name, or nil on failure.

#### client.key\_state

`client.key_state(key: number)`: boolean

| Argument | Type   | Description                                                                                                                                      |
| -------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| **key**  | number | Virtual key code of the key as integer. [List of virtual key codes](https://docs.microsoft.com/en-us/windows/desktop/inputdev/virtual-key-codes) |

Returns true if the key is pressed, or nil on failure

#### client.latency

`client.latency()`: number

Returns your latency in seconds.

#### client.log

`client.log(msg: string[, ...])`

| Argument | Type   | Description                                        |
| -------- | ------ | -------------------------------------------------- |
| **msg**  | string | The message                                        |
| **...**  |        | Comma-separated arguments to concatenate with msg. |

Logs a message to console in the \[gamesense] format.

#### client.random\_float

`client.random_float(minimum: number, maximum: number)`: number

| Argument    | Type   | Description             |
| ----------- | ------ | ----------------------- |
| **minimum** | number | Lowest possible result  |
| **maximum** | number | Highest possible result |

Returns a random float between minimum and maximum.

#### client.random\_int

`client.random_int(minimum: number, maximum: number)`: number

| Argument    | Type   | Description             |
| ----------- | ------ | ----------------------- |
| **minimum** | number | Lowest possible result  |
| **maximum** | number | Highest possible result |

Returns a random integer between minimum and maximum.

#### client.register\_esp\_flag

`client.register_esp_flag(flag: string, r: number, g: number, b: number, callback: function)`

| Argument     | Type     | Description                                                        |
| ------------ | -------- | ------------------------------------------------------------------ |
| **flag**     | string   | String of text that will be shown when callback returns true       |
| **r**        | number   | Red (0-255)                                                        |
| **g**        | number   | Green (0-255)                                                      |
| **b**        | number   | Blue (0-255)                                                       |
| **callback** | function | Function that will be called for each entity while drawing the ESP |

Requires "Flags" is enabled in Player ESP

#### client.reload\_active\_scripts

`client.reload_active_scripts()`

Reloads all scripts the following frame.

#### client.scale\_damage

`client.scale_damage(entindex: number, hitgroup: number, damage: number)`: number

| Argument     | Type                 | Description         |
| ------------ | -------------------- | ------------------- |
| **entindex** | number (entindex)    | Player entity index |
| **hitgroup** | number (hitgroup id) | Hit group index     |
| **damage**   | number               | Damage              |

Returns adjusted damage for the specified hitgroup

#### client.screen\_size

`client.screen_size()`: number, number

Returns (width, height).

#### client.set\_clan\_tag

`client.set_clan_tag(...)`

| Argument | Type | Description                 |
| -------- | ---- | --------------------------- |
| **...**  |      | The text that will be drawn |

The clan tag is removed if no argument is passed or if it is an empty string. Additional arguments will be concatenated similar to client.log.

#### client.set\_event\_callback

`client.set_event_callback(event_name: string, callback: function)`

| Argument        | Type     | Description                                  |
| --------------- | -------- | -------------------------------------------- |
| **event\_name** | string   | Name of the event.                           |
| **callback**    | function | Lua function to call when this event occurs. |

Raises an error and prints a message in console upon failure.

#### client.system\_time

`client.system_time()`: number, number, number, number

Returns windows time as (hours, minutes, seconds, milliseconds)

#### client.timestamp

`client.timestamp()`: number

Returns high precision timestamp in milliseconds.

#### client.trace\_bullet

`client.trace_bullet(from_player: number, from_x: number, from_y: number, from_z: number, to_x: number, to_y: number, to_z: number, skip_players: boolean)`: number, number

| Argument          | Type                      | Description                                                         |
| ----------------- | ------------------------- | ------------------------------------------------------------------- |
| **from\_player**  | number (entindex)         | Entity index of the player whose weapon will be used for this trace |
| **from\_x**       | number (world coordinate) | Position in world space                                             |
| **from\_y**       | number (world coordinate) | Position in world space                                             |
| **from\_z**       | number (world coordinate) | Position in world space                                             |
| **to\_x**         | number (world coordinate) | Position in world space                                             |
| **to\_y**         | number (world coordinate) | Position in world space                                             |
| **to\_z**         | number (world coordinate) | Position in world space                                             |
| **skip\_players** | boolean                   | Optional, pass true to skip expensive hitbox checks.                |

Returns entindex, damage. Entindex is nil when no player is hit or if players are skipped.

#### client.trace\_line

`client.trace_line(skip_entindex: number, from_x: number, from_y: number, from_z: number, to_x: number, to_y: number, to_z: number)`: number, number

| Argument           | Type                      | Description                      |
| ------------------ | ------------------------- | -------------------------------- |
| **skip\_entindex** | number (entindex)         | Ignore this entity while tracing |
| **from\_x**        | number (world coordinate) | Position in world space          |
| **from\_y**        | number (world coordinate) | Position in world space          |
| **from\_z**        | number (world coordinate) | Position in world space          |
| **to\_x**          | number (world coordinate) | Position in world space          |
| **to\_y**          | number (world coordinate) | Position in world space          |
| **to\_z**          | number (world coordinate) | Position in world space          |

Returns fraction, entindex. fraction is a percentage in the range \[0.0, 1.0] that tells you how far the trace went before hitting something, so 1.0 means nothing was hit. entindex is the entity index that hit, or -1 if no entity was hit.

#### client.unix\_time

`client.unix_time()`: number

Returns current windows time as [unix time / epoch time](https://en.wikipedia.org/wiki/Unix_time) (seconds since 1 January 1970 00:00:00)

#### client.unset\_event\_callback

`client.unset_event_callback(event_name: string, callback: function)`

| Argument        | Type     | Description                                          |
| --------------- | -------- | ---------------------------------------------------- |
| **event\_name** | string   | Name of the event                                    |
| **callback**    | function | Lua function that was passed to set\_event\_callback |

Removes a callback that was previously set using set\_event\_callback

#### client.update\_player\_list

`client.update_player_list()`

Updates the player list tab without having to open it.

#### client.userid\_to\_entindex

`client.userid_to_entindex(userid: number)`: number

| Argument   | Type             | Description                        |
| ---------- | ---------------- | ---------------------------------- |
| **userid** | number (user id) | This is given by some game events. |

Returns the entity index, or 0 on failure.

#### client.visible

`client.visible(x: number, y: number, z: number)`: boolean

| Argument | Type                      | Description             |
| -------- | ------------------------- | ----------------------- |
| **x**    | number (world coordinate) | Position in world space |
| **y**    | number (world coordinate) | Position in world space |
| **z**    | number (world coordinate) | Position in world space |

Returns true if the position is visible. For example, you could use a player's origin to see if they are visible.


---

# 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://gamesensical.gitbook.io/docs/developers/globals/client.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.
