[Tool/Web/Other] [Function]IsPlayerNearPlayer
#1

With this function you can easily find is some player near some other player, it is simple to use.

pawn Код:
IsPlayerNearPlayer(playerid, n_playerid, Float:radius){
    new Float:npx, Float:npy, Float:npz;
    GetPlayerPos(n_playerid, npx, npy, npz);
    if(IsPlayerInRangeOfPoint(playerid, radius, npx, npy, npz)){
        return true;
    }else{
        return false;
    }
}
Usage:
pawn Код:
forward IsPlayerNearPlayer(playerid, n_playerid, Float:radius);
IsPlayerNearPlayer(playerid, n_playerid, Float:radius){
    new Float:npx, Float:npy, Float:npz;
    GetPlayerPos(n_playerid, npx, npy, npz);
    if(IsPlayerInRangeOfPoint(playerid, radius, npx, npy, npz)){
        return true;
    }else{
        return false;
    }
}
public OnPlayerCommandText(playerid, cmdtext[]){
  new idx, cmd[256];
  cmd = strtok(cmdtext, idx);
  if(strcmp(cmd, "/near")){
    if(IsPlayerNearPlayer(playerid, 5, 10.0)){
      SendClientMessage(playerid, COLOR_WHITE, "You are near player with id 5 Radius is 10");
      return 1;
    }else{
      SendClientMessage(playerid, COLOR_WHITE, "You are NOT near player with id 5 Radius is 10");
      return 1;
    }
  }
}
So as you can see, with this function we can check is player with example id 5 near player that called command /near
Reply


Messages In This Thread
[Function]IsPlayerNearPlayer - by CoaPsyFactor - 31.07.2010, 05:08
Re: [Function]IsPlayerNearPlayer - by nuriel8833 - 31.07.2010, 06:40
Re: [Function]IsPlayerNearPlayer - by FreshKilla - 31.07.2010, 07:08
Re: [Function]IsPlayerNearPlayer - by DarkPower - 31.07.2010, 09:08
Re: [Function]IsPlayerNearPlayer - by CoaPsyFactor - 01.08.2010, 22:44
Re: [Function]IsPlayerNearPlayer - by ScottCFR - 02.08.2010, 02:21
Re: [Function]IsPlayerNearPlayer - by Young_Monaays - 05.08.2010, 19:00
Re: [Function]IsPlayerNearPlayer - by dice7 - 05.08.2010, 19:03
Re: [Function]IsPlayerNearPlayer - by CoaPsyFactor - 02.01.2011, 19:42

Forum Jump:


Users browsing this thread: 1 Guest(s)