# CFX::TASK_GO_TO_ENTITY

- **Hash:** `0x374827C2`
- **Namespace:** CFX
- **Runtime name (Lua/JS):** `TaskGoToEntity`
- **Side:** server (Cfx runtime native)
- **Name status:** official
- **Documentation:** described
- **URL:** https://natives.borderlinerp.com/natives/CFX/TASK_GO_TO_ENTITY

## Signature

```c
void TASK_GO_TO_ENTITY(Entity entity, Entity target, int duration, float distance, float speed, float p5, int p6);
```

## Parameters

- `entity` (`Entity`)
- `target` (`Entity`)
- `duration` (`int`)
- `distance` (`float`)
- `speed` (`float`)
- `p5` (`float`)
- `p6` (`int`)

## Returns

`void`

## Description

*Source: Cfx.re native reference*

```
The entity will move towards the target until time is over (duration) or get in target's range (distance). p5 and p6 are unknown, but you could leave p5 = 1073741824 or 100 or even 0 (didn't see any difference but on the decompiled scripts, they use 1073741824 mostly) and p6 = 0
Note: I've only tested it on entity -> ped and target -> vehicle. It could work differently on other entities, didn't try it yet.
Example: TASK::TASK_GO_TO_ENTITY(pedHandle, vehicleHandle, 5000, 4.0, 100, 1073741824, 0)
Ped will run towards the vehicle for 5 seconds and stop when time is over or when he gets 4 meters(?) around the vehicle (with duration = -1, the task duration will be ignored).
```

**This is the server-side RPC native equivalent of the client native [TASK_GO_TO_ENTITY](?\_0x6A071245EB0D1882).**

## Usage

### Lua

```lua
TaskGoToEntity(entity, target, duration, distance, speed, p5, p6)

-- always available, by hash
Citizen.InvokeNative(0x374827c2, entity, target, duration, distance, speed, p5, p6)
```

### JavaScript

```js
TaskGoToEntity(entity, target, duration, distance, speed, p5, p6);

// by hash
Citizen.invokeNative('0x374827c2', entity, target, duration, distance + 0.0000001, speed + 0.0000001, p5 + 0.0000001, p6);
```

### C#

```csharp
Function.Call((Hash)0x374827c2, entity, target, duration, distance, speed, p5, p6);
```

- Float parameters: Lua integers (`10`, or whole numbers decoded from NUI/JSON) are sent as ints and read as garbage. Write `10.0` or `value + 0.0`. The generated JS wrappers add `0.0000001` to non-zero floats for the same reason.

*Sources: Cfx.re native reference.*
