Garry's Mod Wiki

Revision Difference

NPC:Disposition#551421

<function name="Disposition" parent="NPC" type="classfunc"> <description>Returns the way the NPC "feels" about the entity.</description> <description>Returns the way the NPC "feels" about a given entity.</description> <realm>Server</realm> <args> <arg name="ent" type="Entity">The entity to get the disposition from.</arg> <arg name="ent" type="Entity">The entity to test our disposition towards.</arg> </args> <rets> <ret name="" type="number">The NPCs disposition, see <page>Enums/D</page>.</ret> </rets> </function> <example> <description>If a player is hurt by a friendly NPC, announce it.</description> <code> function FriendlyFireAnnouncement( ply, atk ) if atk:IsNPC() and atk:Disposition(ply) == D_LI then --like PrintMessage("A "..atk:GetClass().." attacked "..ply:Nick().."!", HUD_PRINTTALK) end end hook.Add( "PlayerHurt", "FriendlyFire", FriendlyFireAnnouncement ) </code> <output>Prints "A ____ attacked ____!" to everyones chat.</output> </example>