BGN_ACTOR:Instance(npc, npc_type, custom_uid, not_sync_actor_on_client, not_auto_added_to_list)
Creates an actor object and associates it with the given NPC.
- npc Entity - The entity of the NPC to bind the.
- npc_type string - NPC type, set in the config "sh_npcs.lua" as a table key.
- custom_uid number (Optional) - The unique number of the actor. This parameter is used to set the ID that was received from the server.
- not_sync_actor_on_client boolean (Optional | Default: false) - if the value is set to "true", then no information about the actor will be sent to clients.
- not_auto_added_to_list boolean (Optional | Default: false) - if the value is set to "true", then the actor will not be automatically added to the general list of all actors.
- ACTOR_CLASS - New actor object.
The code is executed on the server. In this example, an actor with the "citizen" behavior will bind to all NPCs that the player spawns from the spawn menu, after which a message with his unique identifier will be displayed on the console.
hook.Add('PlayerSpawnedNPC', 'BindingActorToNPCFromTheSpawnMenu', function(ply, npc) local actor = BGN_ACTOR:Instance(npc, 'citizen') print('A new actor has been created with ID - ', actor.uid) end)