[Help] Moving Cow - 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: [Help] Moving Cow (
/showthread.php?tid=116791)
[Help] Moving Cow -
Oi! - 30.12.2009
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.
Re: [Help] Moving Cow -
Striker_Moe - 30.12.2009
Its pretty easy. Search for GetClosestPlayer and let the cow follow him. XD
BTW: Whats the cow object ID?
Re: [Help] Moving Cow -
Correlli - 30.12.2009
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);
}
Re: [Help] Moving Cow -
Oi! - 30.12.2009
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.
Re: [Help] Moving Cow -
Striker_Moe - 30.12.2009
I would be able to fix it. Would you accept sending me the script so I can implement the new stuff?
Re: [Help] Moving Cow -
Oi! - 30.12.2009
Do you have MSN?
Re: [Help] Moving Cow -
Striker_Moe - 30.12.2009
Yes, I do. Its mo3@live[DOT]de.
Re: [Help] Moving Cow -
Oi! - 30.12.2009
Alright can anyone else help me with this?
Re: [Help] Moving Cow -
Oi! - 05.01.2010
bump.........