Skip to content

entity_list#

get_entity#

Returns entity object from an entity index or handle

entity_t get_entity(<int> index_or_handle)
Fields Description
index_or_handle
int
entity index or handle

Example

local first_player = entity_list.get_entity(1)
local ground_entity = entity_list.get_entity(first_player:get_prop("m_hGroundEntity"))

get_player_from_userid#

Returns entity object from a player's user id

entity_t get_player_from_userid(<int> user_id)
Fields Description
user_id
int
user id

Example

local victim = entity_list.get_player_from_userid(event_info.userid)
print(victim:get_name())

get_local_player#

Returns local player entity object

entity_t get_local_player()

Example

local local_player = entity_list.get_local_player()
print(local_player:get_prop("m_iHealth")) -- prints player's health

get_local_player_or_spectating#

Returns local_player if alive or currently spectated player

entity_t get_local_player_or_spectating()

Example

local entity = entity_list.get_local_player_or_spectating()
print(entity:get_name()) --print's localplayer name or observer target's name

get_entities_by_classid#

Returns table of entities with the specified class id

entity_t[] get_entities_by_classid(<int> class_id)
Fields Description
class_id
int
class id

Example

local class_list = entity_list.get_entities_by_classid(40)
for i,v in pairs(class_list) do
    print(i,v)
end

get_entities_by_name#

Returns table of entities with the specified name

entity_t[] get_entities_by_name(<string> class_name)
Fields Description
class_name
string
class name

Example

local class_list = entity_list.get_entities_by_name("CCSPlayer")
for i,v in pairs(class_list) do
    print(i,v:get_name())
end

get_players#

Returns table of players

entity_t[] get_players([optional] <bool> enemies_only = false)
Fields Description
enemies_only
bool
[optional] only return enemies

Example

local enemies_only = entity_list.get_players(true)
for _,player in pairs(enemies_only) do
    print("Entity Index: ", player:get_index())
end

get_highest_entity_index#

Returns the maximum entity index

int get_highest_entity_index()

Example

print(entity_list.get_highest_entity_index())