GetPlayerDistanceFromPlayer?
#5

This is the code to check if the player is near you or not. - ( Explaination is in the code. Which is commented)

Код:
CMD:near(playerid, parmas[])
{
     new id,
           idName[MAX_PLAYER_NAME],
           String[128],
           String2[128];
     
     GetPlayerName(id, idName, sizeof(idName)); //Getting the name of the id you are going to input.
     if(sscanf(parmas, "u", id)) return SendClientMessage(playerid, -1, "Usage - /near [id]"); // if id is missing, it will show player message to type in the id.
     if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, -1, "Player not connected!");
     if(id == playerid) return SendClientMessage(playerid, -1, "You can not enter your own id!");
     
     if(GetPlayerDistanceFromPlayer(playerid, id) < 10.0) // If the player is in reach of the player in 10 tiles then it will show the message below.
        {
              
              format(String, sizeof(String), "%s is near you!", idName);
              SendClientMessage(playerid, -1, String);
       }

    else // else it will show this.
      {
              format(String2, sizeof(String2), "%s is not near you!", idName);
              SendClientMessage(playerid, -1, String2);
       }
   
 
return 1;
}
So how GetPlayerDistanceFromPlayer works is -
GetPlayerDistanceFromPlayer(playerid, targetid) < (Tiles distance)

The target id in the above case was id or else it can be anything you want. ed- issuerid, damagedid, etc. Tiles distance can be anything you want. 5.0, 10.0, 20.0 etc.
Reply


Messages In This Thread
GetPlayerDistanceFromPlayer? - by Maheerali - 16.08.2016, 17:41
Re: GetPlayerDistanceFromPlayer? - by DeeadPool - 16.08.2016, 17:48
Re: GetPlayerDistanceFromPlayer? - by Maheerali - 17.08.2016, 14:34
Re: GetPlayerDistanceFromPlayer? - by Shinja - 17.08.2016, 14:37
Re: GetPlayerDistanceFromPlayer? - by DeeadPool - 17.08.2016, 15:35
Re: GetPlayerDistanceFromPlayer? - by SickAttack - 17.08.2016, 15:36
Re: GetPlayerDistanceFromPlayer? - by DeeadPool - 17.08.2016, 15:39
Re: GetPlayerDistanceFromPlayer? - by Maheerali - 19.08.2016, 10:56
Re: GetPlayerDistanceFromPlayer? - by Shinja - 19.08.2016, 11:49
Re: GetPlayerDistanceFromPlayer? - by Maheerali - 21.08.2016, 11:36

Forum Jump:


Users browsing this thread: 4 Guest(s)