Client
PedController

PedController (Client)

RP.PedController manages radius-based entities — peds, vehicles, and objects that are automatically spawned when the player comes within range and despawned when they leave. An internal thread polls every 500 ms.

Entities created by a resource are auto-cleaned up when that resource stops.


Creating radius entities

RP.PedController.CreateRadiusPed(pos, radius, pedOptions, onCreate?, onDespawn?)

--- @param pos        vector3
--- @param radius     number   metres, default 15
--- @param pedOptions table    see options below
--- @param onCreate?  fun(ped: number)
--- @param onDespawn? fun(ped: number)
--- @return number id  handle used to delete the entry
local id = RP.PedController.CreateRadiusPed(
    vector3(100, 200, 30),
    20.0,
    {
        model    = "a_m_y_hipster_01",
        heading  = 180.0,
        invincible = true,
        blockEvents = true,
        freeze   = false,
    },
    function(ped)
        TaskStartScenarioInPlace(ped, "WORLD_HUMAN_STAND_MOBILE", 0, true)
    end,
    function(ped)
        print("ped despawned", ped)
    end
)

RP.PedController.CreateRadiusCar(pos, radius, carOptions, onCreate?, onDespawn?)

Same interface — spawns a local (non-networked) vehicle.

RP.PedController.CreateRadiusObject(pos, radius, objectOptions, onCreate?, onDespawn?)

Spawns a local object.

RP.PedController.CreateRadiusLeaderboardPed(pos, radius, pedOptions, onCreate?, onDespawn?)

Special variant that attaches a leaderboard prop (prop_police_id_board) to the ped and draws a scaleform mugshot board. Used for showing podium-style leaderboard displays in the world.

RP.PedController.CreateRadiusLeaderboardPed(
    vector3(100, 200, 30),
    25.0,
    {
        model = "a_m_y_hipster_01",
        heading = 0.0,
        useFirstBoard = true,
        leaderboardMarkerPos = vector3(100, 196, 30),
    },
    function(ped, setBoardData)
        setBoardData({ "PlayerName", "#1", "1:23.456" })
    end
)

Removing radius entities

RP.PedController.DeleteRadiusEntity(id)

RP.PedController.DeleteRadiusEntity(id)

Entity options

All entity types share these options:

OptionTypeDescription
modelstring | numberModel name or hash (required)
headingnumberSpawn heading (default 0)
invincible / godmodebooleanCalls SetEntityInvincible(true)
freezebooleanCalls FreezeEntityPosition(true)
blockEventsbooleanPeds only — SetBlockingOfNonTemporaryEvents(true)
invisiblebooleanSetEntityVisible(false)
nofadebooleanSkip the fade-in/fade-out animation
fadeTimenumberCustom fade duration in ms (default 900)

leaderboardPed additional options:

OptionTypeDescription
useFirstBoardbooleanUse mugshot_board_01
useSecondBoardbooleanUse mugshot_board_02
useThirdBoardbooleanUse mugshot_board_03
leaderboardMarkerPosvector3Position of the floor arrow marker
💡

If the model fails to load, the entry is automatically removed from the controller and RP.Log.error is called. Check your console for model name typos.