17.03.2011, 14:10
you want any player near certain player?? or a certain player near a certain player?? i will give you both
certain player near certain player
you can now easy use it here is an example(cmd using ZCMD and SSCANF):
easy huh??
now checking if is any player near certain player
you can use it same way as IsPlayerNearPlayer if you need more help post and i will help you
certain player near certain player
pawn Код:
stock IsPlayerNearPlayer(playerid, otherplayerid)//This Will check if "playerid" is near "otherplayerid"
{
new Float:X, Float:Y, Float:Z;
GetPlayerPos(otherplayerid, X, Y, Z);
if(IsPlayerInRangeOfPoint(playerid, 3.0, X, Y, Z)) // 3.0 is the distance from otherplayerid 3.0 is like 2-3 steps away from otherplayerid you can change 3.0 to any thing you want
{
return 1;
}
else
{
return 0;
}
}
pawn Код:
CMD:checkdistance(playerid, params[])
{
new checkingplayerid
if(sscanf(params, "u", checkingplayerid))
{
SendClientMessage(playerid, 0xC0C0C0AA, "Usage:/checkdistance <playerid>");
}
else
{
if(IsPlayerNearPlayer(playerid, checkingplayerid))
{
SendClientMessage(playerid, 0xFFFFFFAA, "You Are Near That Player");
}
}
return 1;
}
now checking if is any player near certain player
pawn Код:
stock IsAnyPlayerNearPlayer(playerid)
{
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
for(new i = 0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(IsPlayerInRangePoint(i, 3.0, X, Y, Z)) // again you can increase 3.0
{
return 1;
}
else
{
return 0;
}
}
}
}