How to make NPC directed against a player??? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: How to make NPC directed against a player??? (
/showthread.php?tid=132492)
How to make NPC directed against a player??? -
mysql - 07.03.2010
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.
Re: How to make NPC directed against a player??? -
boelie - 23.03.2010
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
Re: How to make NPC directed against a player??? -
Torran - 23.03.2010
[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?