Skip to main content

Spawn

The spawn module is available on the client. It spawns peds and objects, applies common entity options, supports proximity-based streaming with ox_lib points, and tracks handles for cleanup.

Spawn a ped

Spawn an object

Options

boolean
Calls FreezeEntityPosition(handle, freeze).
boolean
Calls SetEntityInvincible(handle, invincible).
boolean
Defaults to enabled. Set false to disable entity collision.
number
Calls SetEntityAlpha(handle, alpha, false).
boolean
Spawns the entity as networked when set to true.
table
Object-only rotation table with x, y, and z.
boolean
Ped-only option for SetBlockingOfNonTemporaryEvents.
boolean
Ped-only option for SetPedDiesWhenInjured.
string
Ped-only scenario passed to TaskStartScenarioInPlace.
table
Ped-only animation with dict, clip, and optional flag.

Proximity streaming

Use spawnOnNear when an entity should only exist while the player is close to a point.
spawnOnNear.coords and spawnOnNear.radius are required. Without despawnRadius, sure_lib uses radius * 1.5.

Scoped cleanup

Scopes let you clean up a set of spawned handles and stream entries together.
function
Deletes every globally tracked spawned entity and removes all stream points registered through the module.
function
Deletes entities and stream entries created through that scope only.
sure_lib also calls spawn:deleteAll() when the current resource stops.