Skip to content

Commit

Permalink
feat(gamestate/server): add GET_ENTITY_TYPE_RAW native
Browse files Browse the repository at this point in the history
Implements a new custom (server) native to get the specific NetObjEntity type of a networked entity.
  • Loading branch information
tens0rfl0w committed Nov 19, 2024
1 parent 4f7d5fa commit c2ad330
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,11 @@ static void Init()
return (int)GetEntityType(entity);
}));

fx::ScriptEngine::RegisterNativeHandler("GET_ENTITY_TYPE_RAW", makeEntityFunction([](fx::ScriptContext& context, const fx::sync::SyncEntityPtr& entity)
{
return entity->type;
}, -1));

fx::ScriptEngine::RegisterNativeHandler("SET_ROUTING_BUCKET_POPULATION_ENABLED", [](fx::ScriptContext& context)
{
int bucket = context.GetArgument<int>(0);
Expand Down
75 changes: 75 additions & 0 deletions ext/native-decls/GetEntityTypeRaw.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
---
ns: CFX
apiset: server
---
## GET_ENTITY_TYPE_RAW

```c
int GET_ENTITY_TYPE_RAW(Entity entity);
```
Gets the specific entity type (as an integer), which can be one of the following defined down below:
#### FiveM:
```c
enum eNetObjEntityType
{
Automobile = 0,
Bike = 1,
Boat = 2,
Door = 3,
Heli = 4,
Object = 5,
Ped = 6,
Pickup = 7,
PickupPlacement = 8,
Plane = 9,
Submarine = 10,
Player = 11,
Trailer = 12,
Train = 13
};
```

#### RedM:
```c
enum eNetObjEntityType
{
Animal = 0,
Automobile = 1,
Bike = 2,
Boat = 3,
Door = 4,
Heli = 5,
Object = 6,
Ped = 7,
Pickup = 8,
PickupPlacement = 9,
Plane = 10,
Submarine = 11,
Player = 12,
Trailer = 13,
Train = 14,
DraftVeh = 15,
StatsTracker = 16,
PropSet = 17,
AnimScene = 18,
GroupScenario = 19,
Herd = 20,
Horse = 21,
WorldState = 22,
WorldProjectile = 23,
Incident = 24,
Guardzone = 25,
PedGroup = 26,
CombatDirector = 27,
PedSharedTargeting = 28,
Persistent = 29
};
```

## Parameters
* **entity**: The entity to get the specific type of.

## Return value
The specific entity type returned as an integer value or -1 if the entity is invalid.

0 comments on commit c2ad330

Please sign in to comment.