Entity.Disposition

From GMod Wiki

Jump to: navigation, search
Function
Syntax Entity:Disposition( Entity target )
Description:
Returns the way one entity feels about another. Really, this should be used on an NPC, and target should be an NPC or a player. The returned value corresponds to a disposition enumeration.
Returns: Integer
In Object: Entity
Realm: NewerServer.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Entity.Disposition]Entity.Disposition [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Examples

DescriptionIf a player is hurt by a friendly NPC, announce it.
Used onNewerServer.png
Code
function FriendlyFireAnnouncement( ply, atk )
	if atk:IsNPC() and atk:Disposition(ply) == 3 then -- 3 means like, or friend
		for k,v in pairs( player.GetAll() ) do
			v:ChatPrint( "A "..atk:GetClass().." attacked "..ply:Nick().."!"
		end
	end
end
 
hook.Add( "PlayerHurt", "FriendlyFire", FriendlyFireAnnouncement )
OutputPrints "A ____ attacked ____!" to chat


See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox