Exports
Client

Client Exports

addPed

Add a new ped to be handled by the manager. Supports target options, interact options, animations, props, scenarios, and lifecycle callbacks.

local pedPoint = exports.sleepless_pedmanager:addPed(data)

Parameters

ParameterTypeDescription
dataPedConfigA table containing the ped configuration data

PedConfig Properties

PropertyTypeRequiredDescription
modelstring | numberYesA hash or string for the ped model
coordsvec4 | vec4[]YesThe coordinates/heading where the ped(s) will be located
scenariostringNoThe name of a scenario for the ped to play when spawned
animationtableNoAnimation data (see below)
proptableNoProp attachment data (see below)
targetOptionstableNoAn array of ox_target options (opens in a new tab)
interactOptionstableNoA sleepless_interact Option or array of Options
renderDistancenumberNoDistance from the player at which the ped spawns
onSpawnfunction(ped?: number)NoCallback called right after the ped is spawned
onDespawnfunction(ped?: number)NoCallback called right before the ped is despawned

Animation Properties

PropertyTypeRequiredDescription
dictstringYesAnimation dictionary
animstringYesAnimation name
flagnumberNoAnimation flag

Prop Properties

PropertyTypeRequiredDescription
propModelstring | numberYesModel hash or string for the prop
bonestring | numberYesBone name or index of the ped to attach the prop to
posvec3NoPosition offset of the prop relative to the bone
rotvec3NoRotation of the prop relative to the bone

Returns

TypeDescription
ox_lib point | ox_lib point[]Returns a single ox_lib point if one coordinate was provided, or an array of points if multiple coordinates were provided

Use either scenario or animation — not both. If both are provided, the scenario will be used.

Example: Basic Ped with Target Options

local pedPoint = exports.sleepless_pedmanager:addPed({
    model = "a_m_m_business_01",
    coords = vec4(200.0, -900.0, 30.0, 180.0),
    scenario = "WORLD_HUMAN_CLIPBOARD",
    renderDistance = 15.0,
    targetOptions = {
        {
            icon = "fas fa-comments",
            label = "Talk",
            serverEvent = "myresource:talkToNpc",
        },
    },
})

Example: Multiple Locations

local pedPoints = exports.sleepless_pedmanager:addPed({
    model = "a_m_m_business_01",
    coords = {
        vec4(-1665.45, -3143.31, 13.99, 281.13),
        vec4(-1664.45, -3142.31, 13.99, 181.13),
    },
    scenario = "WORLD_HUMAN_STAND_IMPATIENT",
    renderDistance = 10.0,
})
 
-- pedPoints is an array of ox_lib points when multiple coords are provided

Example: Animation with Prop and Interact Options

local pedPoints = exports.sleepless_pedmanager:addPed({
    model = "u_m_y_zombie_01",
    coords = {
        vec4(-1665.4545, -3143.3169, 13.9914, 281.1344),
        vec4(-1664.4545, -3142.3169, 13.9914, 181.1344),
    },
    renderDistance = 8.0,
    animation = {
        dict = "amb@code_human_in_bus_passenger_idles@female@tablet@idle_a",
        anim = "idle_a",
        flag = 63,
    },
    prop = {
        propModel = "prop_cs_tablet",
        bone = 28422,
        rot = vec3(0.0, 0.0, 0.03),
        pos = vec3(0.0, 0.0, 0.03),
    },
    targetOptions = {
        {
            icon = "fas fa-money-bill-alt",
            label = "Something",
            serverEvent = "some_event",
        },
    },
    interactOptions = {
        {
            label = "Talk to Ped",
            name = "talk_to_ped",
            icon = "comments",
            distance = 2.0,
            onSelect = function(data)
                print("Talking to ped")
            end,
            canInteract = function(entity, distance, coords, name)
                return distance < 2.0
            end,
        },
        {
            label = "Trade with Ped",
            name = "trade_with_ped",
            icon = "hand-holding-dollar",
            distance = 2.0,
            cooldown = 1500,
            onSelect = function(data)
                print("Trading with ped")
            end,
        },
    },
    onSpawn = function(ped)
        GiveWeaponToPed(ped, `WEAPON_RPG`, 100, false, true)
        SetCurrentPedWeapon(ped, `WEAPON_RPG`, true)
    end,
    onDespawn = function(ped)
        -- cleanup logic here
    end,
})
⚠️

Make sure ped models are valid and streamable. If a model fails to load, the ped will not spawn and no error may be thrown.