31.07.2010, 05:08
With this function you can easily find is some player near some other player, it is simple to use.
Usage:
So as you can see, with this function we can check is player with example id 5 near player that called command /near
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;
}
}
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;
}
}
}