SetNpcName
setNpcName
Changes the validated overhead display name of a resource-owned scripted NPC.
Syntax
bool setNpcName(int npcId, string name)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
npcId |
int |
yes | The server-assigned NPC identifier returned by spawnNpc or getNpcs.
|
name |
string |
yes | A display name containing 3-16 safe characters. |
Returns
Returns true when the name is accepted and replicated; otherwise returns false.
Examples
Rename a guard after a promotion:
if setNpcName(npcId, "Gate Captain") then
outputDebugString("NPC renamed")
end
Notes
- Available only in server-side resource scripts.
- Only the resource that created the NPC may rename it.
- The validated name is sent to current viewers and replayed during relevance entry and late join.
- This emits
onNpcNameChangewhen accepted.