LookAtPlayer

From NPC for VCMP 0.4 Servers
Revision as of 05:02, 6 September 2024 by Habi (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


Description:
The function sets the angle of the npc, making it face the player.


Parameters:

(playerid)

playerid : The ID of the player the npc will face.


Return Values:
Returns true on success and false on failure (npc not spawned, npc inside vehicle, or target player not connected). Using npc ID as player id results in undefined behaviour.


Example

function OnPlayerText(playerid, message)
{
	if(message=="lookatme")
	{
		if(GetDistanceFromMeToPoint(GetPlayerPos(playerid))<100.0)
		{
			LookAtPlayer(playerid);
		}
	}
}

Related Functions

The following functions may be helpful as they relate to this function in one way or another.