Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(natives/object): add documentation for DELETE_OBJECT #1163

Merged
merged 2 commits into from
Aug 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 71 additions & 17 deletions OBJECT/DeleteObject.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,71 @@
---
ns: OBJECT
---
## DELETE_OBJECT

```c
// 0x539E0AE3E6634B9F 0xD6EF9DA7
void DELETE_OBJECT(Object* object);
```

```
Deletes the specified object, then sets the handle pointed to by the pointer to NULL.
```

## Parameters
* **object**:

---
ns: OBJECT
---
## DELETE_OBJECT

```c
// 0x539E0AE3E6634B9F 0xD6EF9DA7
void DELETE_OBJECT(Object* object);
```

Deletes the specified object.

**Note**: If for some reason the entity won't delete, you might want to check if the object is a mission entity.

```
NativeDB Introduced: v323
```

## Parameters
* **object**: The object you want to delete.

## Examples
```lua
local playerPed = PlayerPedId()
local playerCoords = GetEntityCoords(playerPed)
local objectHash = GetHashKey("v_ret_gc_chair03")

local object = GetClosestObjectOfType(playerCoords, 10.0, objectHash, true, false, false)
if object == 0 then return end

-- If the object is a mission entity, we have to set it to false. Otherwise, it won't be possible to delete the object.
if IsEntityAMissionEntity(object) then
SetEntityAsMissionEntity(object, false, true)
end

DeleteObject(object)
```

```js
const playerPed = PlayerPedId();
const playerCoords = GetEntityCoords(playerPed, false);
const objectHash = GetHashKey("v_ret_gc_chair03");

const object = GetClosestObjectOfType(playerCoords[0], playerCoords[1], playerCoords[2], 10.0, objectHash, true, false, false);
if (object === 0) return;

// If the object is a mission entity, we have to set it to false. Otherwise, it won't be possible to delete the object.
if (IsEntityAMissionEntity(object)) {
SetEntityAsMissionEntity(object, false, true);
}

DeleteObject(object);
```

```csharp
using static CitizenFX.Core.Native.API;

int playerPed = PlayerPedId();
Vector3 playerCoords = GetEntityCoords(playerPed, false);
uint objectHash = Game.GenerateHashASCII("v_ret_gc_chair03");

int prop = GetClosestObjectOfType(playerCoords.X, playerCoords.Y, playerCoords.Z, 10.0f, objectHash, true, false, false);
if (prop == 0) return;
// If the object is a mission entity, we have to set it to false. Otherwise, it won't be possible to delete the object.
if (IsEntityAMissionEntity(prop))
{
SetEntityAsMissionEntity(prop, false, true);
}

DeleteObject(ref prop);
```
Loading