# SimObject

### Examples:

#### Objects Iteration:

```squirrel
for (local i = SimObject.GetHead(); i; i = i.GetNext())
{
    // Do something...
}
```

### Properties:

### Static Functions:

#### .Create

`SimObject.Create(model: Hash, coords: Vector3, rotation: Vector3)`: SimObject

| Argument | Type    | Description            |
| -------- | ------- | ---------------------- |
| model    | Hash    | -                      |
| coords   | Vector3 | Position of new Object |
| rotation | Vector3 | Rotation of new Object |

Returns SimObject when successfully created.

#### .GetHead

`SimObject.GetHead()`: SimObject

Returns first SimObject in ObjectsTree.

#### .GetNext

`SimObject.GetNext()`: SimObject

Returns next SimObject from ObjectsTree.

### Functions:

#### .SetDestroyOnUnload

`SimObject.SetDestroyOnUnload(toggle: boolean)`

| Argument | Type    | Description |
| -------- | ------- | ----------- |
| toggle   | boolean | -           |

You can toggle if the current SimObject should be destroyed when script gets unloaded.

{% hint style="info" %}
When you create any SimObject by default it will be set to be destroyed on unload, but you can override it by calling this function with toggle value to false.
{% endhint %}

#### .Destroy

`SimObject.Destroy()`

Destroys a SimObject. Please note `SimObject` will not become null.

#### .Restore

`SimObject.Restore()`

Restores all suspended components.

#### .Suspend

`SimObject.Suspend()`

Suspends all components. Note: some certain Objects will need to be suspend each [OnGameUpdate](https://sneakyevil.gitbook.io/sleeping-dogs-de-script-api/callbacks/ongameupdate).

#### .GetName

`SimObject.GetName()`: Hash

Returns a SimObject name as hash.

#### .GetPropertyName

`SimObject.GetPropertyName()`: Hash

Returns a SimObject property name as hash, this is basically the model hash you use for creating SimObject.

#### .GetType

`SimObject:GetType()`: [SimObjectType](https://sneakyevil.gitbook.io/sleeping-dogs-de-script-api/enums#simobjecttype)

#### .GetPosition

`SimObject.GetPosition()`: Vector3

#### .SetPosition

`SimObject.SetPosition(coords: Vector3)`

| Argument | Type    | Description       |
| -------- | ------- | ----------------- |
| coords   | Vector3 | World coordinates |

#### .GetRotation

`SimObject.GetRotation()`: Vector3

#### .SetRotation

`SimObject.SetRotation(euler: Vector3)`

| Argument | Type    | Description       |
| -------- | ------- | ----------------- |
| euler    | Vector3 | Rotation in euler |

### Attachment Functions:

#### .GetAttachmentCount

`SimObject.GetAttachmentCount()`: integer

Returns count of attached SimObjects to current SimObject.

#### .GetAttachments

`SimObject.GetAttachments()`: array\[SimObject]

Returns array of SimObjects that are attached to current SimObject.


---

# 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://sneakyevil.gitbook.io/sleeping-dogs-de-script-api/game-classes/simobject.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.
