SetNpcWeapon: Difference between revisions

From Wiki G1R-MP G1 Remake Multiplayer
Jump to navigation Jump to search
Update Lua API reference
 
Complete Lua function catalog
 
Line 32: Line 32:
* Use <code>getPlayerWeaponNames</code> to enumerate supported keys.
* Use <code>getPlayerWeaponNames</code> to enumerate supported keys.


[[Category:Lua Functions]]
[[Category:Server Functions]]
[[Category:Server Functions]]
[[Category:World Functions]]
[[Category:World Functions]]
[[Category:NPC Functions]]
[[Category:NPC Functions]]
[[Category:Equipment Functions]]
[[Category:Equipment Functions]]

Latest revision as of 09:55, 15 August 2026

setNpcWeapon

Changes the authoritative weapon of a resource-owned scripted NPC.

Syntax

bool setNpcWeapon(int npcId, string itemKey)

Parameters

Name Type Required Description
npcId int yes The server-assigned NPC identifier returned by spawnNpc or getNpcs.
itemKey string yes A validated key returned by getPlayerWeaponNames; armor and weapon accept none to clear the slot.

Returns

Returns true when the validated change is accepted and replicated; otherwise returns false.

Examples

Change an NPC's weapon:

setNpcWeapon(npcId, "none")

Notes

  • Available only in server-side resource scripts.
  • The state is sent reliably to current viewers and replayed on relevance entry and late join.
  • Raw Unreal object paths are never accepted from Lua.
  • Use getPlayerWeaponNames to enumerate supported keys.