👤Ped Helper

What it does

Spawns static NPCs with animation, creates a proximity point, shows hold UI on entry, and calls your callback on completion. Auto‑cleans on exit.

Register :

  • Signature : pedRegister(model, pos, heading, name, anim, interact) -> index

  • Anim : string scenario or {dict, name, flag}

  • Interact : {message, icon?, intent?, holdKey?, holdTime?, interactRange?, holdDistance?, onInteract?}

Example :

local CFG = {
    coords = vec3(-33.415382, -1099.951660, 25.415405),
    heading = 70.866142,
    model = "mp_m_weapexp_01",
    animDict = "amb@world_human_stand_mobile@male@text@base",
    animName = "base",
    animFlag = 1,
    message = "Go to the shooting range",
    icon = "Crosshair",
    intent = "success",
    holdKey = 38, -- E
    holdTime = 1.0,
    interactRange = 4.0,
    holdDistance = 2.0,
    offsetZ = 1.0,
    blips = {
        sprite = 119,
        color = 50,
        text = "Shooting range",
        road = false,
        scale = 0.8,
        display = 5,
        alpha = 255
    }
}

exports["Var-Interact"]:pedRegister(
    CFG.model,
    CFG.coords,
    CFG.heading,
    nil,
    {dict = CFG.animDict, name = CFG.animName, flag = CFG.animFlag},
    {
        message = CFG.message,
        icon = CFG.icon,
        intent = CFG.intent,
        holdKey = CFG.holdKey,
        holdTime = CFG.holdTime,
        interactRange = CFG.interactRange,
        holdDistance = CFG.holdDistance,
        offsetZ = CFG.offsetZ,
        onInteract = function(i, ped, spec)
            print("Interacted with ped", i, ped, spec)
        end
    }
)
  • Batch init : Ped:InitFromLists(lists) to register from tables in bulk.

Last updated