client
addPed

addPed

add a new ped to be handled by the manager. allows for target options, animations, props, scenarios and more

Parameters

  • data (PedConfig): A table containing the config data.
    • model (string | number): A hash or string for the ped model.
    • coords (vec4 | vec4[]): The coordinates/heading where the ped(s) will be located.
    • scenario? (string): The name of a scenario for the ped to play when spawned
    • animation? (table): table of animation data
      • dict (string): animation dictionary
      • anim (string): animation name
      • flag? (number): animation flag
    • prop? (table): table of prop data
      • propModel (string or number): model hash or string for the prop
      • bone (string or number): bone name or index of the ped to attach the prop to
      • pos? (vec3): position of the prop relative to the bone its attached to
      • rot? (vec3): rotation of the prop relative to the bone its attached to
    • targetOptions? (table): an array of ox_target options (opens in a new tab)
    • interactOptions? (table): a sleepless_interact Option or array of Options
    • renderDistance? (number): distance from the player at which the ped spawns
    • onSpawn? (function(ped?: number)): a function that gets called right AFTER the ped is spawned
    • onDespawn? (function(ped?: number)): a function that gets called right BEFORE the ped is despawned

Returns

  • ox_lib point instance

Example

local pedPoint = 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,
        -- scenario = "WORLD_HUMAN_CLIPBOARD", --optionally use a scenario or an animation.
        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,
            rotation = vec3(0.0, 0.0, 0.03),
            offset = vec3(0.0, 0.0, 0.03),
        },
        targetOptions = { --whatever normal options for ox_target
            {
                icon = 'fas fa-money-bill-alt',
                label = 'something',
                serverEvent = "some event"
            },
        },
        interactOptions = { -- sleepless_interact v2 options
            {
                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)
        end
})