Skip to content
Open
Show file tree
Hide file tree
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
112 changes: 112 additions & 0 deletions pages/ox_lib/Modules/CreateObject/Client.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
import { Tabs, Tab } from 'nextra-theme-docs';

# Client

Spawn an object client-side. Loads the model, calls `CreateObject`, then releases the model.

## lib.createObject

<Tabs items={["FiveM", "RedM"]}>
<Tab>
<Tabs items={["Lua", "JS"]}>
<Tab>
```lua
lib.createObject(model, coords, isNetwork, netMissionEntity, doorFlag, heading, rotation)
```
</Tab>
<Tab>
```ts
import lib from '@overextended/ox_lib/client'

lib.createObject(model, coords, isNetwork, netMissionEntity, doorFlag, heading, rotation)
```
</Tab>
</Tabs>

- model: `string | number`
- Model name or precomputed hash.
- coords: `vector3`
- World coordinate to spawn the object at.
- isNetwork?: `boolean`
- Create as a network object. If `false`, the object exists only locally.
- Default: `false`
- netMissionEntity?: `boolean`
- Pin the object to the script host in the R\* network model.
- Default: `false`
- doorFlag?: `boolean`
- Set `true` to spawn door models in network mode.
- Default: `false`
- heading?: `number`
- Heading of the object, in degrees.
- rotation?: `vector3`
- Rotation of the object. If omitted the object spawns with no rotation.

**Returns:**
- entity: `number`
- Entity handle, or `0` if the object could not be created.

```lua
local object = lib.createObject(
'prop_chair_01a',
GetEntityCoords(cache.ped),
true, true, false,
GetEntityHeading(cache.ped)
)
```
</Tab>

<Tab>
<Tabs items={["Lua", "JS"]}>
<Tab>
```lua
lib.createObject(model, coords, isNetwork, bScriptHostObj, dynamic, p7, p8, heading, rotation)
```
</Tab>
<Tab>
```ts
import lib from '@overextended/ox_lib/client'

lib.createObject(model, coords, isNetwork, bScriptHostObj, dynamic, p7, p8, heading, rotation)
```
</Tab>
</Tabs>

- model: `string | number`
- Model name or precomputed hash.
- coords: `vector3`
- World coordinate to spawn the object at.
- isNetwork?: `boolean`
- Create as a network object. If `false`, the object exists only locally.
- Default: `false`
- bScriptHostObj?: `boolean`
- Pin the object to the script host in the R\* network model.
- Default: `false`
- dynamic?: `boolean`
- Whether the object should be dynamic (physics-driven, can move).
- Default: `false`
- p7?: `boolean`
- Undocumented RedM parameter forwarded to the native.
- Default: `false`
- p8?: `boolean`
- Undocumented RedM parameter forwarded to the native.
- Default: `false`
- heading?: `number`
- Heading of the object, in degrees.
- rotation?: `vector3`
- Rotation of the object. If omitted the object spawns with no rotation.

**Returns:**
- entity: `number`
- Entity handle, or `0` if the object could not be created.

```lua
local object = lib.createObject(
'p_amb_tent01x',
GetEntityCoords(cache.ped),
true, true, false,
nil, nil,
GetEntityHeading(cache.ped)
)
```
</Tab>
</Tabs>
60 changes: 60 additions & 0 deletions pages/ox_lib/Modules/CreateObject/Server.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { Tabs, Tab } from 'nextra-theme-docs';

# Server

Spawn an object server-side. The helper waits for the entity to materialize and applies
an orphan mode so the entity is not cleaned up automatically.

## lib.createObject

<Tabs items={["Lua", "JS"]}>
<Tab>
```lua
lib.createObject(model, coords, doorFlag, heading, rotation, orphanMode)
```
</Tab>
<Tab>
```ts
import lib from '@overextended/ox_lib/server'

lib.createObject(model, coords, doorFlag, heading, rotation, orphanMode)
```
</Tab>
</Tabs>

- model: `string | number`
- Model name or precomputed hash.
- coords: `vector3`
- World coordinate to spawn the object at.
- doorFlag?: `boolean`
- Set `true` to spawn door models in network mode.
- Default: `false`
- heading?: `number`
- Heading of the object, in degrees.
- rotation?: `vector3`
- Rotation of the object. If omitted the object spawns with no rotation.
- orphanMode?: `EntityOrphanMode`
- Server-side cleanup behavior applied via `SetEntityOrphanMode`.
- Default: `2` (KeepEntity)

**Returns:**
- entity: `number`
- Entity handle, or `0` if the object could not be created.

### EntityOrphanMode

```
0 DeleteWhenNotRelevant — default game behavior; deletes when no player is relevant.
1 DeleteOnOwnerDisconnect — deletes when the original owner disconnects.
2 KeepEntity — never deleted by server relevancy checks.
```

```lua
local playerPed = GetPlayerPed(source)
local object = lib.createObject(
'prop_chair_01a',
GetEntityCoords(playerPed),
false,
GetEntityHeading(playerPed)
)
```
104 changes: 104 additions & 0 deletions pages/ox_lib/Modules/CreatePed/Client.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import { Tabs, Tab } from 'nextra-theme-docs';

# Client

Spawn a ped client-side. Loads the model, calls `CreatePed`, then releases the model.

## lib.createPed

<Tabs items={["FiveM", "RedM"]}>
<Tab>
<Tabs items={["Lua", "JS"]}>
<Tab>
```lua
lib.createPed(pedType, model, coords, heading, isNetwork, bScriptHostPed)
```
</Tab>
<Tab>
```ts
import lib from '@overextended/ox_lib/client'

lib.createPed(pedType, model, coords, heading, isNetwork, bScriptHostPed)
```
</Tab>
</Tabs>

- pedType: `number`
- AI behavior type. `4` = CIVMALE, `5` = CIVFEMALE, etc.
- model: `string | number`
- Model name or precomputed hash.
- coords: `vector3`
- World coordinate to spawn the ped at.
- heading?: `number`
- Heading of the ped, in degrees.
- isNetwork?: `boolean`
- Create as a network ped. If `false`, the ped exists only locally.
- Default: `false`
- bScriptHostPed?: `boolean`
- Pin the ped to the script host in the R\* network model.
- Default: `false`

**Returns:**
- entity: `number`
- Entity handle, or `0` if the ped could not be created.

```lua
local ped = lib.createPed(
4,
'a_m_y_business_01',
GetEntityCoords(cache.ped),
GetEntityHeading(cache.ped),
true, true
)
```
</Tab>

<Tab>
<Tabs items={["Lua", "JS"]}>
<Tab>
```lua
lib.createPed(model, coords, heading, isNetwork, bScriptHostPed, p7, p8)
```
</Tab>
<Tab>
```ts
import lib from '@overextended/ox_lib/client'

lib.createPed(model, coords, heading, isNetwork, bScriptHostPed, p7, p8)
```
</Tab>
</Tabs>

- model: `string | number`
- Model name or precomputed hash.
- coords: `vector3`
- World coordinate to spawn the ped at.
- heading?: `number`
- Heading of the ped, in degrees.
- isNetwork?: `boolean`
- Create as a network ped. If `false`, the ped exists only locally.
- Default: `false`
- bScriptHostPed?: `boolean`
- Pin the ped to the script host in the R\* network model.
- Default: `false`
- p7?: `boolean`
- Undocumented RedM parameter forwarded to the native.
- Default: `false`
- p8?: `boolean`
- Undocumented RedM parameter forwarded to the native.
- Default: `false`

**Returns:**
- entity: `number`
- Entity handle, or `0` if the ped could not be created.

```lua
local ped = lib.createPed(
'mp_male',
GetEntityCoords(cache.ped),
GetEntityHeading(cache.ped),
true, true
)
```
</Tab>
</Tabs>
57 changes: 57 additions & 0 deletions pages/ox_lib/Modules/CreatePed/Server.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { Tabs, Tab } from 'nextra-theme-docs';

# Server

Spawn a ped server-side. The helper waits for the entity to materialize and applies an
orphan mode so the ped is not cleaned up automatically.

## lib.createPed

<Tabs items={["Lua", "JS"]}>
<Tab>
```lua
lib.createPed(pedType, model, coords, heading, orphanMode)
```
</Tab>
<Tab>
```ts
import lib from '@overextended/ox_lib/server'

lib.createPed(pedType, model, coords, heading, orphanMode)
```
</Tab>
</Tabs>

- pedType: `number`
- AI behavior type. `4` = CIVMALE, `5` = CIVFEMALE, etc. Ignored on RedM (`Unused` per the native docs).
- model: `string | number`
- Model name or precomputed hash.
- coords: `vector3`
- World coordinate to spawn the ped at.
- heading?: `number`
- Heading of the ped, in degrees.
- orphanMode?: `EntityOrphanMode`
- Server-side cleanup behavior applied via `SetEntityOrphanMode`.
- Default: `2` (KeepEntity)

**Returns:**
- entity: `number`
- Entity handle, or `0` if the ped could not be created.

### EntityOrphanMode

```
0 DeleteWhenNotRelevant — default game behavior; deletes when no player is relevant.
1 DeleteOnOwnerDisconnect — deletes when the original owner disconnects.
2 KeepEntity — never deleted by server relevancy checks.
```

```lua
local playerPed = GetPlayerPed(source)
local ped = lib.createPed(
4,
'a_m_y_business_01',
GetEntityCoords(playerPed),
GetEntityHeading(playerPed)
)
```
Loading