How to make NPC directed against a player???
#1

How to make a npc aiming on some player?
And another question how to make npc player just move forwoard without recording if thats possible? Because I can place it anywere and it will move forwoard.
Reply
#2

make a command on your gamemode that includes the function;

SetPlayerToFacePlayer(playerid, targetid)

this function is in the a_angles include so make sure you include that in your gamemode to
heres an example of my command under onplayercommandtext ;

Код:
	if(!strcmp(cmdtext, "/face", true))//
	{	for(new i = 0; i < MAX_PLAYERS; i++)
	  if(i!=playerid)
	  {
		if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
		{
		if(GetPlayerState(i) == PLAYER_STATE_ONFOOT)
		{
		if(GetDistanceBetweenPlayers(playerid,i) < 5 )//modify this number to your needs
		{
		SetPlayerToFacePlayer(playerid, i);
		}
		}
		}
		}
		return 1;
	}
Now all you have to do is go to the npc script and add the /face command there somewhere

for example under OnplayerText and then it sends the command..the npc will face you


this gives you an example of how it could work
Reply
#3

[quote=boelie ]
make a command on your gamemode that includes the function;

SetPlayerToFacePlayer(playerid, targetid)

this function is in the a_angles include so make sure you include that in your gamemode to
heres an example of my command under onplayercommandtext ;

Код:
	if(!strcmp(cmdtext, "/face", true))//
	{	for(new i = 0; i < MAX_PLAYERS; i++)
	  if(i!=playerid)
	  {
		if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
		{
		if(GetPlayerState(i) == PLAYER_STATE_ONFOOT)
		{
		if(GetDistanceBetweenPlayers(playerid,i) < 5 )//modify this number to your needs
		{
		SetPlayerToFacePlayer(playerid, i);
		}
		}
		}
		}
	

arent both getdistancebetweenplayers and setplayertofaceplayer custom functions?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)