Garry's Mod Wiki

Revision Difference

GM:OnNPCDropItem#565320

<function name="OnNPCDropItem" parent="GM" type="hook"> <description>Called whenever an NPC drops an item upon it's death.⤶ <note>It will be called only for entities the NPC creates. It will NOT be called for dropped weapons (with exception of Half-Life: Source NPCs, since they don't use actual weapon entities, they create the weapons on death). <page>GM:PlayerDroppedWeapon</page> works for NPC weapon drops already. (Yes, I know it says PLAYERDroppedWeapon, it works because the hook is called from the weapon itself, not from the dropping entity) </note> <description>⤶ Called whenever an NPC drops an item upon its death, such as health kits, armor batteries, etc. It will NOT be called for dropped weapons, with exception of Half-Life: Source NPCs, since they don't use actual weapon entities and create a weapon entity on death. <page>GM:PlayerDroppedWeapon</page> works for NPC weapon drops already. (Yes, it's not a typo) ⤶ It will also not be called for live grenades spawned by Zombine. </description> <added>2025.07.28</added> <realm>Server</realm> <args> <arg name="npc" type="NPC">The killed NPC</arg> <arg name="item" type="Entity">The item that got dropped by the NPC.</arg> </args> </function> <example> <description>Removes the item an NPC drops upon it spawning</description> <code> hook.Add( "OnNPCDropItem", "RemoveNPCDrops", function( npc, item ) item:Remove() end) end ) </code> </example>