> For the complete documentation index, see [llms.txt](https://fecality-api.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://fecality-api.gitbook.io/docs/documentation/namespaces/entities.md).

# Entities

entities namespace

## Functions

### get\_entity

```lua
entities.get_entity(engine.get_local_player())
```

| [Parameter](broken://pages/UU4tqPUKMSAYAyywZ4hX) | [Datatype](broken://pages/UU4tqPUKMSAYAyywZ4hX) | [Description](broken://pages/UU4tqPUKMSAYAyywZ4hX) |
| :----------------------------------------------: | :---------------------------------------------: | :------------------------------------------------: |
|                   entity index                   |                      number                     |                entity's server index               |

#### Returns:

| [Value](broken://pages/UU4tqPUKMSAYAyywZ4hX) | [Datatype](broken://pages/UU4tqPUKMSAYAyywZ4hX) |
| :------------------------------------------: | :---------------------------------------------: |
|                entity's object               |  [entity](broken://pages/r9AdrdKuqfx1ehYTW5QN)  |

### get\_entity\_from\_handle

```lua
entities.get_entity_from_handle(local_player:get_prop("m_hMyWeapons", 1))
```

| [Parameter](broken://pages/UU4tqPUKMSAYAyywZ4hX) | [Datatype](broken://pages/UU4tqPUKMSAYAyywZ4hX) |   [Description](broken://pages/UU4tqPUKMSAYAyywZ4hX)   |
| :----------------------------------------------: | :---------------------------------------------: | :----------------------------------------------------: |
|                   entity handle                  |                      number                     | <p>a handle to the entity<br>ex: m\_hMyWeapons\[1]</p> |

#### Returns:

| [Value](broken://pages/UU4tqPUKMSAYAyywZ4hX) | [Datatype](broken://pages/UU4tqPUKMSAYAyywZ4hX) |
| :------------------------------------------: | :---------------------------------------------: |
|                entity's object               |  [entity](broken://pages/r9AdrdKuqfx1ehYTW5QN)  |

### for\_each

```lua
entities.for_each(function(entity)
    print(string.format("Entity's index: %i", entity:get_index()))
end)
```

| [Parameter](broken://pages/UU4tqPUKMSAYAyywZ4hX) | [Datatype](broken://pages/UU4tqPUKMSAYAyywZ4hX) |                  [Description](broken://pages/UU4tqPUKMSAYAyywZ4hX)                 |
| :----------------------------------------------: | :---------------------------------------------: | :---------------------------------------------------------------------------------: |
|                 function callback                |                     function                    | <p>A function to use as a callback. </p><p>Must have 1 argument for the entity.</p> |

#### Usage:

Runs for each entity on the server.

### for\_each\_z

```lua
entities.for_each_z(function(entity)
    print(string.format("Entity's index: %i", entity:get_index()))
end)
```

| [Parameter](broken://pages/UU4tqPUKMSAYAyywZ4hX) | [Datatype](broken://pages/UU4tqPUKMSAYAyywZ4hX) |                  [Description](broken://pages/UU4tqPUKMSAYAyywZ4hX)                 |
| :----------------------------------------------: | :---------------------------------------------: | :---------------------------------------------------------------------------------: |
|                 function callback                |                     function                    | <p>A function to use as a callback. </p><p>Must have 1 argument for the entity.</p> |

#### Usage:

Runs for each entity on the server starting from the end.

### for\_each\_player

```lua
entities.for_each_player(function(player)
    print(string.format("Player: %i has %i health", 
    player:get_index(), 
    player:get_prop("m_iHealth")))
end)
```

| [Parameter](broken://pages/UU4tqPUKMSAYAyywZ4hX) | [Datatype](broken://pages/UU4tqPUKMSAYAyywZ4hX) |                  [Description](broken://pages/UU4tqPUKMSAYAyywZ4hX)                 |
| :----------------------------------------------: | :---------------------------------------------: | :---------------------------------------------------------------------------------: |
|                 function callback                |                     function                    | <p>A function to use as a callback. </p><p>Must have 1 argument for the player.</p> |

#### Usage:

Runs for each player on the server.
