entities
Properties
Name | Type | Description |
---|---|---|
local_player |
entity | Local player |
__index
entities[{id: number}]
-> entity
Accesses an entity by its index.
Parameters
Name | Type | Description |
---|---|---|
id |
number | Entity index |
Usage
local local_player = entities[engine.get_local_player()];
get_entity
entities.get_entity(id: number)
-> entity
Accesses an entity by its index.
Parameters
Name | Type | Description |
---|---|---|
id |
number | Entity index |
Usage
local local_player = entities.get_entity(engine.get_local_player());
get_entity_from_handle
entities.get_entity_from_handle(handle: number)
-> entity
Accesses an entity by its handle.
Parameters
Name | Type | Description |
---|---|---|
id |
number | Entity handle |
Usage
-- returns the first weapon the local_player holds
entities.get_entity_from_handle(local_player.m_hMyWeapons[0]);
for_each
entities.for_each(fn: (entity))
Runs a given function for every entity.
Parameters
Name | Type | Description |
---|---|---|
fn |
function(entity) | Loop callback |
Usage
entities.for_each(function(entity)
print('Entity index: ' .. entity:get_index());
end);
for_each_z
entities.for_each_z(fn: (entity))
Runs a given function for every entity in reverse order.
Parameters
Name | Type | Description |
---|---|---|
fn |
function(entity) | Loop callback |
Usage
entities.for_each_z(function(entity)
print('Entity index: ' .. entity:get_index());
end);
for_each_player
entities.for_each_player(fn: (entity))
Runs a given function for every entity that is a player.
Parameters
Name | Type | Description |
---|---|---|
fn |
function(entity) | Loop callback |
Usage
entities.for_each_player(function(player)
print('Player health: ' .. player:get_prop('m_iHealth'));
end);