Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.sure-developer.com/llms.txt

Use this file to discover all available pages before exploring further.

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.
local spawn = sure.getModule('spawn')

Spawn a ped

local handle = spawn:ped('a_m_m_business_01', {
  x = 1,
  y = 2,
  z = 3
}, 90.0, {
  alpha = 180,
  blockEvents = true,
  collision = false,
  freeze = true,
  invincible = true,
  networked = true,
  scenario = 'WORLD_HUMAN_CLIPBOARD'
})

Spawn an object

local prop = spawn:object('prop_barrel_02a', {
  x = 10,
  y = 20,
  z = 30
}, {
  freeze = true,
  rotation = {
    x = 0,
    y = 0,
    z = 90
  }
})

Options

freeze
boolean
Calls FreezeEntityPosition(handle, freeze).
invincible
boolean
Calls SetEntityInvincible(handle, invincible).
collision
boolean
Defaults to enabled. Set false to disable entity collision.
alpha
number
Calls SetEntityAlpha(handle, alpha, false).
networked
boolean
Spawns the entity as networked when set to true.
rotation
table
Object-only rotation table with x, y, and z.
blockEvents
boolean
Ped-only option for SetBlockingOfNonTemporaryEvents.
diesOnInjury
boolean
Ped-only option for SetPedDiesWhenInjured.
scenario
string
Ped-only scenario passed to TaskStartScenarioInPlace.
animation
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.
local entry = spawn:ped('a_m_m_business_01', coords, 180.0, {
  spawnOnNear = {
    coords = vector3(50, 60, 70),
    radius = 5,
    despawnRadius = 8,
    onNear = function(state)
      print(state.handle, state.distance, state.spawned)
    end
  }
})
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.
local scope = spawn:scope()

local object = scope:object('prop_beachflag_le', coords, {
  alpha = 0,
  collision = false,
  freeze = true
})

scope:deleteAll()
spawn:deleteAll()
function
Deletes every globally tracked spawned entity and removes all stream points registered through the module.
scope:deleteAll()
function
Deletes entities and stream entries created through that scope only.
sure_lib also calls spawn:deleteAll() when the current resource stops.