# Functions

## TrackEntity

Function to start tracking an entity for its deletion

```lua
function HRLib.TrackEntity(
    entityId: integer,
    attachedInfo: table<string, any>?,
    cb: fun(entityType: 'vehicle'|'ped'|'object')?    
)
```

Parameters description

* `entityId` - the id of the entity to track
* `attachedInfo` - a table where you can set additional info to the properties in the event trigger
* `cb` - a callback function to trigger during entity check if you of course want to do something with the entity in each check or to add additional info to the properties in the event trigger but needs to be triggered on each check

## GetIsEntityTracked

Function to check if an entity is being tracked by the function [TrackEntity](#trackentity)

```lua
function HRLib.GetIsEntityTracked(entityId: integer): boolean
```

Parameters description

* `entityId` - the id of the entity to check

## GetTrackedEntityProperties

Function to get the last values set to the properties in the last check

```lua
function HRLib.GetTrackedEntityProperties(entity: integer, index: string?): any?
```

Parameters description

* `entity` - the entity id to get the properties of
* `index` - index of the properties if you're not interested to get all the properties\
  (if `nil`, it will return all the properties)

## GetTrackedEntities

Function to get all tracked entities from the player

```lua
function HRLib.GetTrackedEntities(): { entity: integer, properties: table }[]?
```

## RemoveEntityTracker

Function to stop tracking entity

```lua
function HRLib.RemoveEntityTracker(entityId: integer)
```

Parameters description

* `entityId` - the entity id to remove the tracker of


---

# 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://hrscripts.gitbook.io/hrscripts-documentation/resources/hrlib/modules/trackingentities/client/functions.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.
