[Help] Moving Cow
#1

Okay guys. I made this cow in my script that will follow you around if you're the first one to the place that it spawns. However... I would like for the cow to follow the closest player to it. How can I make this possible? And I've seen it on another server it's just a little tricky. If you'd like the IP to my server then write in a comment below so I can show you what I'm talking about.
Reply
#2

Its pretty easy. Search for GetClosestPlayer and let the cow follow him. XD

BTW: Whats the cow object ID?
Reply
#3

I don't know who created this function but it can be found on the forum:
pawn Код:
stock GetClosestPlayer(playerid)
{
  new
      Float:dis, Float:dis2, player;
  player = -1;
  dis = 99999.99;
  for(new i = 0; i < MAX_PLAYERS; i++)
  {
    dis2 = GetDistanceBetweenPlayers(i, playerid);
    if((dis2 < dis) && (dis2 != -1.00))
    {
      dis = dis2;
      player = i;
    }
  }
  return player;
}
You will also need this function:
pawn Код:
stock GetDistanceBetweenPlayers(playerid, playerid2)
{
  new
      Float:x1, Float:y1, Float:z1,
      Float:x2, Float:y2, Float:z2, Float:tmpdis;
  GetPlayerPos(playerid, x1, y1, z1);
  GetPlayerPos(playerid2, x2, y2, z2);
  tmpdis = floatsqroot(floatpower(floatabs(floatsub(x2, x1)), 2) + floatpower(floatabs(floatsub(y2, y1)), 2) + floatpower(floatabs(floatsub(z2, z1)), 2));
  return floatround(tmpdis);
}
Reply
#4

Cow ID: 16442

I'll give you my script that nobody has but me if you help me fix this. Like I said it's working accept the whole follow the closest player and the rotation of the cow, so that the face of the cow looks at the player.
Reply
#5

I would be able to fix it. Would you accept sending me the script so I can implement the new stuff?
Reply
#6

Do you have MSN?
Reply
#7

Yes, I do. Its mo3@live[DOT]de.
Reply
#8

Alright can anyone else help me with this?
Reply
#9

bump.........
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)