> For the complete documentation index, see [llms.txt](https://docs.autowall.fun/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.autowall.fun/documentation/vars/entity.md).

# Entity

## <i class="fa-bezier-curve">:bezier-curve:</i> Entity

{% hint style="warning" %}
Players are exposed as **lightuserdata** wrapping a raw `c_player_controller*` — treat them as opaque handles, valid only for the frame/event you got them in. Don't cache a player handle across frames; call `entity.get_local_player()` / `entity.get_players()` again each time instead.
{% endhint %}

```lua
entity.get_local_player()       -- lightuserdata | nil
entity.get_local_player_addr()  -- integer (raw pointer value)

entity.get_players()            -- array of tables, see below
entity.get_name(player)          -- string
entity.is_alive(player)          -- bool
entity.is_enemy(player)          -- bool (team differs from local player's team)
entity.get_origin(player)        -- vector
entity.get_prop(player, key)     -- see keys below
```

### `entity.get_players()` entry

```lua
{
    controller = <lightuserdata>,
    controller_addr = <integer>,
    name = "PlayerName",
    health = 100,
    team = 1,             -- team_t: 0=none, 1=tr, 2=ct, 3=spectator
    visible = true,
    teammate = false,     -- team == local player's team
    origin = vector(x, y, z),
}
```

### `entity.get_prop(player, key)` keys

| key                        | returns            |
| -------------------------- | ------------------ |
| `"health"`                 | integer            |
| `"team"` / `"m_eTeam"`     | integer (`team_t`) |
| `"name"` / `"player_name"` | string             |
| `"origin"` / `"position"`  | vector             |

Unknown keys return `nil`.

#### Example

```lua
events.render:set(function()
    for _, p in ipairs(entity.get_players()) do
        local col = p.teammate and color(0, 255, 0) or color(255, 0, 0)
        local sx, sy, ok = render.world_to_screen(p.origin.x, p.origin.y, p.origin.z)
        if ok then
            render.text("verdana", {sx, sy}, col, string.format("%s [%d]", p.name, p.health))
        end
    end
end)
```

### Not implemented yet

{% hint style="danger" %}
`entity.get_weapons()`, `entity.get_thrown_grenades()`, `entity.set_prop`, `entity.get_weapon(player)`, `entity.get_velocity(player)`, `entity.get_bone_position(player, idx)` are **not implemented** — see Roadmap.
{% endhint %}


---

# 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://docs.autowall.fun/documentation/vars/entity.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.
