Configuration ​
Everything is in Config.NpcHandler in shared/config.lua. It is a shared file, loaded on the client and the
server. Some values can also be changed live in np_admin (Editable in np_admin).
General ​
Config.NpcHandler = {
enabled = true,
debug = false,
maxDefinitions = 2048,
maxRequestIdLength = 64,
restrict = { … },
interactEvents = {},
definitions = {},
-- definition, spawn, sync, streaming, interaction, population, control,
-- requests, incidents, client and the reaction vocabulary: below
}
| Key | Default | Description |
|---|---|---|
enabled |
true |
false stops all spawning and makes every client request fail closed. Registrations are still accepted |
debug |
false |
Prints for registrations, spawns and owner clean-up (server console) and failed networked upkeep (F8) |
maxDefinitions |
2048 |
Most NPCs registered at once on the server. A client refuses addLocalNpc once it holds this many NPCs in total |
maxRequestIdLength |
64 |
Longest perception request id |
interactEvents |
{} |
Interact events allowed for any resource, as a set: { ['np_shops:open'] = true }. Other events must start with the owner's resource name and a colon |
definitions |
{} |
NPCs owned by np_npchandler itself. Same shape as registerNpc. Rejected entries are printed at start |
Restrictions ​
restrict = {
models = nil,
scenarios = nil,
animDicts = nil,
weapons = nil,
roles = nil,
incidentCategories = nil,
},
Each list is optional. nil accepts any well-formed value from a trusted export. A set such as
{ mp_m_shopkeep_01 = true } accepts only those values.
| Key | Checked against | Refused with |
|---|---|---|
models |
The NPC model and held prop models (names or hashes) | 'model_not_allowed', 'invalid_props' |
scenarios |
scenario, after resolving a v0.2.0 alias |
'scenario_not_allowed' |
animDicts |
anim.dict |
'invalid_anim' |
weapons |
weapon names (upper case) |
'invalid_weapon' |
roles |
role |
'role_not_allowed' |
incidentCategories |
The category a policy returns | 'incident_category_not_allowed' |
Definition limits ​
Checked when an NPC is registered or created. NPCs already registered keep their values.
definition = {
coordinateLimit = 10000.0,
zMin = -1000.0,
zMax = 3000.0,
maxRoutingBucket = 65535,
minSpawnDistance = 5.0,
maxSpawnDistance = 400.0,
defaultLocalSpawnDistance = 60.0,
defaultNetworkedSpawnDistance = 120.0,
minDespawnDelayMs = 0,
maxDespawnDelayMs = 300000,
minPerceptionRadius = 1.0,
maxPerceptionRadius = 25.0,
minInteractionRadius = 0.5,
maxInteractionRadius = 5.0,
minCooldownMs = 250,
maxCooldownMs = 300000,
maxPolicies = 8,
maxInteractions = 16,
maxPatrolPoints = 32,
maxOutfitEntries = 16,
maxHeldProps = 4,
maxInteractOptions = 6,
maxCombatAttributes = 16,
maxConditionEntries = 32,
maxDataDepth = 4,
maxDataEntries = 32,
maxDataStringLength = 256,
},
| Key | Default | Description |
|---|---|---|
coordinateLimit |
10000.0 |
Largest absolute x and y |
zMin / zMax |
-1000.0 / 3000.0 |
Allowed z range |
maxRoutingBucket |
65535 |
Highest routingBucket |
minSpawnDistance / maxSpawnDistance |
5.0 / 400.0 |
Allowed spawnDistance |
defaultLocalSpawnDistance |
60.0 |
spawnDistance of a local NPC that sets none |
defaultNetworkedSpawnDistance |
120.0 |
spawnDistance of a networked NPC that sets none |
minDespawnDelayMs / maxDespawnDelayMs |
0 / 300000 |
Allowed per-NPC despawnDelayMs |
minPerceptionRadius / maxPerceptionRadius |
1.0 / 25.0 |
Allowed perception.radius |
minInteractionRadius / maxInteractionRadius |
0.5 / 5.0 |
Allowed perception.interactionRadius |
minCooldownMs / maxCooldownMs |
250 / 300000 |
Allowed reaction cooldowns, from the definition and from policies |
maxPolicies / maxInteractions |
8 / 16 |
Entries in policies / interactionIds |
maxPatrolPoints |
32 |
Points in patrol.points |
maxOutfitEntries |
16 |
Entries in outfit.components and in outfit.props |
maxHeldProps |
4 |
Entries in props |
maxCombatAttributes |
16 |
Entries in combatAttributes |
maxInteractOptions |
6 |
Options in one interact list |
maxConditionEntries |
32 |
Names in one jobs or gangs list |
maxDataDepth / maxDataEntries / maxDataStringLength |
4 / 32 / 256 |
Limits of the data table |
Networked spawning ​
Server side, for networked NPCs and server immediate peds.
spawn = {
enabled = true,
requireOneSync = true,
maxNetworkedPeds = 64,
pollIntervalMs = 1000,
scopePollIntervalMs = 2000,
cellSize = 128.0,
despawnMargin = 15.0,
scopeMargin = 25.0,
despawnDelayMs = 15000,
maxSpawnsPerTick = 4,
rehydrateDelayMs = 5000,
incapacitatedDelayMs = 15000,
maxRetries = 3,
orphanMode = 2,
bucketPollIntervalMs = 2000,
},
| Key | Default | Description |
|---|---|---|
enabled |
true |
Second switch: both this and enabled must be on before the server creates peds |
requireOneSync |
true |
Refuse to create peds while the onesync convar is off |
maxNetworkedPeds |
64 |
Cap for every ped the server creates: streamed, alwaysSpawned and server immediate peds together |
pollIntervalMs |
1000 |
Interval of the server pass: spawns, deletions, alive and death checks (at least 250 ms) |
scopePollIntervalMs |
2000 |
How often player positions are matched against the server grid |
cellSize |
128.0 |
Server grid cell size |
despawnMargin |
15.0 |
A spawned ped stays while a player is within spawnDistance + this |
scopeMargin |
25.0 |
Runtime state and dialogue cues go to players within spawnDistance + this |
despawnDelayMs |
15000 |
Default delay between "nobody in range" and deletion. An NPC can set its own despawnDelayMs |
maxSpawnsPerTick |
4 |
Peds created per server pass, nearest first |
rehydrateDelayMs |
5000 |
Default respawn.delayMs: wait before a lost ped is created again |
incapacitatedDelayMs |
15000 |
Default respawn.deadDelayMs: how long a dead ped stays before it is replaced |
maxRetries |
3 |
Default respawn.maxRetries: failed creations in a row before the server waits for players to leave |
orphanMode |
2 |
Value for SetEntityOrphanMode. 2 keeps the entity when its owner leaves |
bucketPollIntervalMs |
2000 |
How often each player's routing bucket is read and pushed to them on change |
Sync ​
sync = {
snapshotWindowMs = 10000,
maxSnapshotsPerPlayer = 3,
latentSnapshotThreshold = 64,
latentBytesPerSecond = 200000,
},
| Key | Default | Description |
|---|---|---|
snapshotWindowMs / maxSnapshotsPerPlayer |
10000 / 3 |
A player gets at most this many snapshots per window. Clients retry after the window plus 5 s |
latentSnapshotThreshold |
64 |
Snapshots with more NPCs are sent as a latent event |
latentBytesPerSecond |
200000 |
Bandwidth of latent snapshots |
Local streaming ​
Client side, for local NPCs and preview peds.
streaming = {
cellSize = 64.0,
despawnMargin = 10.0,
despawnDelayMs = 10000,
pollIntervalMs = 500,
idlePollIntervalMs = 2000,
moveThreshold = 2.0,
revalidateIntervalMs = 10000,
maxSpawnsPerTick = 2,
maxLocalPeds = 48,
modelLoadTimeoutMs = 5000,
animLoadTimeoutMs = 3000,
retryDelayMs = 30000,
networkTimeoutMs = 3000,
},
| Key | Default | Description |
|---|---|---|
cellSize |
64.0 |
Client grid cell size |
despawnMargin |
10.0 |
A spawned ped is only hidden beyond spawnDistance + this |
despawnDelayMs |
10000 |
Default delayed delete: a hidden ped is deleted after this. An NPC can set its own despawnDelayMs |
pollIntervalMs |
500 |
Interval of the client pass |
idlePollIntervalMs |
2000 |
Interval while nothing is registered, created or overridden |
moveThreshold |
2.0 |
A pass is skipped while the player stays within this distance of the last scanned position and nothing changed |
revalidateIntervalMs |
10000 |
A full pass still runs this often while standing still |
maxSpawnsPerTick |
2 |
Local peds created per pass, nearest first |
maxLocalPeds |
48 |
Cap for local peds per client: streamed NPCs plus createLocalPed peds |
modelLoadTimeoutMs |
5000 |
A model that takes longer counts as failed |
animLoadTimeoutMs |
3000 |
Timeout for anim dicts of anim and playAnim |
retryDelayMs |
30000 |
An NPC whose model timed out is tried again after this. Models missing from the game files are never tried again |
networkTimeoutMs |
3000 |
Client-created networked peds: how long to wait for the creation ticket and for the ped to become networked |
Interaction ​
interaction = {
provider = 'auto',
fallback = false,
promptId = 'np_npchandler',
greetCooldownMs = 30000,
},
| Key | Default | Description |
|---|---|---|
provider |
'auto' |
'auto' takes np_hud, then ox_target, then qb-target, then 'fallback' when fallback is on, else 'none'. Or force one of 'np_hud', 'ox_target', 'qb-target', 'fallback', 'none' |
fallback |
false |
Built-in 3D text with a key, used only when no other provider runs |
promptId |
'np_npchandler' |
Prompt id used with np_hud's ShowPrompt / HidePrompt |
greetCooldownMs |
30000 |
Minimum time between two speech.greet lines of one NPC |
Minigames ​
minigames = {
enabled = true,
maxMove = 2.0, -- metres a player may move during the game before it fails ('moved')
distanceTolerance = 3.0, -- redeemInteraction: interact.distance (+ wander / guard radius) + this
},
Off, or np_minigames not started: interactions fire without a game and redeemInteraction answers
{ success = true, skipped = true }. See Interaction → Minigames.
Population ​
population = {
areaCheckIntervalMs = 500,
clearIntervalMs = 1000,
clearRangeMargin = 100.0,
},
| Key | Default | Description |
|---|---|---|
areaCheckIntervalMs |
500 |
How often the client works out which density overrides apply to the player |
clearIntervalMs |
1000 |
How often suppressed areas are cleared while the player is near |
clearRangeMargin |
100.0 |
"Near" a suppressed area means within its radius + this |
See Ambient population.
Runtime control ​
control = {
maxDistance = 60.0,
windowMs = 10000,
maxPerPlayer = 30,
},
| Key | Default | Description |
|---|---|---|
maxDistance |
60.0 |
A routed control request needs the player within this distance of the ped. A routed walkTo target must be within this distance of the ped |
windowMs / maxPerPlayer |
10000 / 30 |
Rate limit per player for routed control requests, and separately for client-ped tickets, registrations and deletions |
See Appearance & behaviour → Runtime control.
Reactions ​
Limits of the reaction system.
requests = {
arbitrationWindowMs = 75,
reactionDurationMs = 2500,
windowMs = 10000,
maxPerPlayer = 12,
maxPerNpc = 24,
maxPendingPerNpc = 16,
maxReplayIdsPerPlayer = 64,
duplicateRetentionMs = 30000,
},
incidents = {
cooldownMs = 8000,
playerWindowMs = 60000,
maxPerPlayer = 3,
npcWindowMs = 60000,
maxPerNpc = 10,
globalWindowMs = 60000,
maxGlobal = 100,
retentionMs = 120000,
maxDedupEntries = 2048,
maxSeverity = 5,
},
client = {
perceptionEnabled = true,
nearPollIntervalMs = 250,
farPollIntervalMs = 1500,
animationLoadTimeoutMs = 1500,
maxRequestAgeMs = 15000,
},
| Key | Default | Description |
|---|---|---|
requests.arbitrationWindowMs |
75 |
Requests for one NPC are collected this long, then the first valid one wins |
requests.reactionDurationMs |
2500 |
How long an accepted reaction holds the NPC |
requests.windowMs |
10000 |
Rate-limit window for requests |
requests.maxPerPlayer / maxPerNpc |
12 / 24 |
Requests per window, per player and per NPC |
requests.maxPendingPerNpc |
16 |
Requests waiting in one arbitration window |
requests.maxReplayIdsPerPlayer / duplicateRetentionMs |
64 / 30000 |
Request ids remembered per player to refuse replays, and for how long |
incidents.cooldownMs |
8000 |
Dedup window: one incident per NPC, player, category and policy version in this window (or the policy cooldown, if longer) |
incidents.playerWindowMs / maxPerPlayer |
60000 / 3 |
Incidents per player per window |
incidents.npcWindowMs / maxPerNpc |
60000 / 10 |
Incidents per NPC per window |
incidents.globalWindowMs / maxGlobal |
60000 / 100 |
Incidents per window, all NPCs |
incidents.retentionMs / maxDedupEntries |
120000 / 2048 |
How long dedup keys are kept, and how many |
incidents.maxSeverity |
5 |
Highest severity a policy may return |
client.perceptionEnabled |
true |
Clients send a request when they come close to a perception NPC |
client.nearPollIntervalMs / farPollIntervalMs |
250 / 1500 |
Perception check interval with and without a perception NPC near |
client.animationLoadTimeoutMs |
1500 |
Timeout for gesture anim dicts of dialogue cues |
client.maxRequestAgeMs |
15000 |
A request without an answer is cancelled after this |
Reaction vocabulary ​
allowedScenarios = {
stand_impatient = 'WORLD_HUMAN_STAND_IMPATIENT',
stand_guard = 'WORLD_HUMAN_GUARD_STAND',
stand_mobile = 'WORLD_HUMAN_STAND_MOBILE',
},
allowedPolicies = {
allow = { kind = 'builtin', decision = 'allow' },
ignore = { kind = 'builtin', decision = 'ignore' },
warn = { kind = 'builtin', decision = 'warn' },
escalate = { kind = 'builtin', decision = 'escalate', incidentCategory = 'npc_policy_escalation', severity = 1 },
['np_shops:staff_only_policy'] = { kind = 'owned' },
['np_shops:hostile_response_policy'] = { kind = 'owned' },
['np_service:assistance_policy'] = { kind = 'owned' },
},
allowedInteractions = {
autonomous_perception = { handler = 'optional' },
shop_greeting = { handler = 'optional' },
shop_staff_warning = { handler = 'required' },
shop_hostile_response = { handler = 'required' },
service_assistance = { handler = 'required' },
},
dialogueSets = {
basic_staff = { allow = 'greeting', warn = 'warning', escalate = 'dismissal' },
},
dialogueCues = {
greeting = { speech = 'GENERIC_HI', speechParameter = 'SPEECH_PARAMS_FORCE_NORMAL_CLEAR', gesture = 'hello' },
warning = { speech = 'GENERIC_CURSE_MED', speechParameter = 'SPEECH_PARAMS_FORCE_NORMAL_CLEAR', gesture = 'no_way' },
dismissal = { speech = 'GENERIC_INSULT_HIGH', speechParameter = 'SPEECH_PARAMS_FORCE_SHOUTED_CLEAR', gesture = 'dismiss' },
},
gestures = {
hello = { dictionary = 'gestures@m@standing@casual', clip = 'gesture_hello', durationMs = 1800 },
no_way = { dictionary = 'gestures@m@standing@casual', clip = 'gesture_no_way', durationMs = 1800 },
dismiss = { dictionary = 'gestures@m@standing@casual', clip = 'gesture_hand_down', durationMs = 1800 },
},
| Key | Description |
|---|---|
allowedScenarios |
Short scenario names kept for definitions written against v0.2.0. Any native scenario name (WORLD_HUMAN_*, PROP_HUMAN_*, …) is accepted too |
allowedPolicies |
Built-in policies (kind = 'builtin') with their fixed decision. Entries with kind = 'owned' only document known adapters: any safe id except the built-ins can be registered with registerPolicy |
allowedInteractions |
Interaction ids. handler = 'required' means the NPC's owner must register an interaction handler for it. Unknown safe ids are accepted with an optional handler |
dialogueSets |
Maps a decision to a cue id. An NPC picks a set with dialogueSet |
dialogueCues |
The speech line, speech parameter and gesture of a cue. Cue ids are the only values accepted from policies |
gestures |
Anim dict, clip and duration of a gesture |
Editable in np_admin ​
When np_admin is running, 34 of these options can be changed in its Resource settings page
(NPC handler). shared/config.lua stays the default; np_admin stores only the values you override. Without
np_admin, the config is used as written.
| Category | Fields |
|---|---|
| General | enabled, debug, maxDefinitions |
| Spawning | spawn.enabled, spawn.pollIntervalMs, .rehydrateDelayMs, .incapacitatedDelayMs, .maxRetries, .requireOneSync, .maxNetworkedPeds, .maxSpawnsPerTick, .despawnDelayMs |
| Local peds | streaming.maxLocalPeds, streaming.maxSpawnsPerTick, streaming.despawnDelayMs |
| Requests | requests.windowMs, .maxPerPlayer, .maxPerNpc, .arbitrationWindowMs, .reactionDurationMs |
| Incidents | incidents.cooldownMs, .maxPerPlayer, .maxPerNpc, .maxGlobal, .maxSeverity |
| Client | client.perceptionEnabled, client.nearPollIntervalMs, client.farPollIntervalMs, client.animationLoadTimeoutMs, interaction.fallback |
| Definitions | definition.maxPerceptionRadius, definition.maxInteractionRadius, definition.minCooldownMs, definition.maxCooldownMs |
Every field applies live. Turning enabled or spawn.enabled on or off sends every client a fresh snapshot. The
definition bounds are checked on registration, so they affect new or updated NPCs only.
The restrict lists, interactEvents, definitions and the reaction vocabulary (scenarios, policies,
interactions, dialogue sets, cues, gestures) stay config-only.
The debug command is gated by the np_admin node np_npchandler.debug. See Events → Commands.