LookAtPlayer: Difference between revisions

From NPC for VCMP 0.4 Servers
Jump to navigation Jump to search
No edit summary
No edit summary
 
Line 6: Line 6:
function OnPlayerText(playerid, message)
function OnPlayerText(playerid, message)
{
{
if(message=="lookAtMe")
if(message=="lookatme")
{
{
if(GetDistanceFromMeToPoint(GetPlayerPos(playerid))<100.0)
if(GetDistanceFromMeToPoint(GetPlayerPos(playerid))<100.0)

Latest revision as of 05:02, 6 September 2024


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.