Garry's Mod Wiki

Revision Difference

NPC:Disposition#510702

<function name="Disposition" parent="NPC" type="classfunc">⤶ <description>Returns the way the NPC "feels" about the entity.</description>⤶ <realm>Server</realm>⤶ <args>⤶ <arg name="ent" type="Entity">The entity to get the disposition from.</arg>⤶ </args>⤶ <rets>⤶ <ret name="" type="number">The NPCs disposition, see <page>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>