Skip to content

NewReignStudios/nrs-pedmanager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nrs-pedmanager Overview

nrs-pedmanager is a resource which manages the dynamic spawning and despawning of local peds. It handles the spawning and despawning of peds based on the players distance from the ped. It also handles the despawning of peds when the resource which spawned them is stopped. It also handles a number of common natives called on peds.

It is recomended to use this resource for more static peds (i.e. shops), rather then more dynamic peds. This is because the peds are despawned when the player is a certain distance away from the ped. This can cause issues with peds which are moving around the world.

Setup

nrs-pedmanger is used as an 'import' resource. This means that it is started by other resources which use it. To use nrs-pedmanager, you must add it to the resources which start it in the fxmanifest.lua file. You can do this by adding the following lines to the fxmanifest.lua file of the resource which will be utilizing nrs-pedmanager.

shared_scripts {
    '@ox_lib/init.lua',
    -- Your files here
}
client_scripts {
    '@nrs-pedmanager/client.lua',
    -- Your files here
}

Then, in your resource files, you can start nrs-pedmanager by calling the following function.

SetupPeds(pedTable)

and access the peds by thier name like

nrs_peds['PedName'].entityID

ped data has the following properties

You can also add peds directly to nrs-pedmanager by adding them to the Config.Peds table

Notes

Do not use DeleteEntity or DeletePed to remove peds, becuase they will just respawn the next time the player enters the spawn radius. Instead use the remove function on the ped data to remove the ped if it is spawned and prevent it from spawning again. If you later need to spawn the ped again, call the SetupPeds function again.

Example Config.Peds

Use this teplate to create your peds

Config.Peds = {
    ['PedName'] = {
        --Required Details
        model = 'modelname',
        coords = vector3(x, y, z),
        -- Optional Details

        -- heading = 0.0,
        -- debug = true,
        -- spawnRadius = 25,
        -- invincible = false,
        -- frozen = false,
        -- blockEvents = false,
        -- bScriptHostPed = false,
        -- canBeTargetted = true,
        -- animation
        -- animDict = '',
        -- animName = '',
        -- OR
        -- scenario
        -- scenario = '',
        -- playEnterAnim = true -- false by default, try if sencario wont play
        -- ox_target
        -- target = {
        --     {
        --         name = 'ox:option1',
        --         event = 'ox_target:debug',
        --         icon = 'fa-solid fa-road',
        --         label = 'Option 1',
        --         distance = 3
        --     },
        --     {
        --         name = 'ox:option2',
        --         event = 'ox_target:debug',
        --         icon = 'fa-solid fa-road',
        --         label = 'Option 2',
        --         distance = 3
        --     }
        -- }
        -- OR
        -- qb-target
        -- target = {
        --     options = {
        --         {
        --             icon = 'fas fa-dollar-sign',
        --             label = 'Option 1',
        --             event = 'example'
        --         },
        --          {
        --             icon = 'fas fa-dollar-sign',
        --             label = 'Option 2',
        --             event = 'example'
        --         }
        --     },
        --     distance = 3
        -- },
        -- Anything else you need for the resource here, this wont be used by pedmanager

        -- blip = {
        --     label = 'BlipName',
        --     sprite = 628,
        --     color = 3
        -- }
    }
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages