Distance
#4

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
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;
    }
}
you can now easy use it here is an example(cmd using ZCMD and SSCANF):
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;
}
easy huh??

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;
                     }
                }
          }
}
you can use it same way as IsPlayerNearPlayer if you need more help post and i will help you
Reply


Messages In This Thread
Distance - by GiS - 17.03.2011, 13:24
Re: Distance - by Mike Garber - 17.03.2011, 13:35
Re: Distance - by Mauzen - 17.03.2011, 13:44
Re: Distance - by AH.1990 - 17.03.2011, 14:10
Re: Distance - by ricardo178 - 17.03.2011, 14:13
Re: Distance - by AH.1990 - 17.03.2011, 14:15

Forum Jump:


Users browsing this thread: 2 Guest(s)