How to know if a player is near another player
#1

Hello. I want to make a good /pay command, so I want the receiver to be near the giver, but I don't know how to script this! Any help?
Reply
#2

Lets start off with the player position.
Put this right under the command
pawn Код:
new Float:x, Float:y, Float:z;
Now we will get his position
pawn Код:
GetPlayerPos(playerid,x, y, z);
I assume you used sscanf so we'll check if any one is near the player
pawn Код:
if(!IsPlayerInRangeOfPoint(targetid,5,x,y,z)return SendClientMessage(playerid,-1,"There isn't a near by player");
And that's it.
Reply
#3

Get the player's position and the use it in IsPlayerInRangeOfPoint function and check if he is near the other player.
Reply
#4

How I do it:

pawn Код:
if (ProxDetectorS(8.0, playerid, giveplayerid))
            {
                                //Your action
                         }
Reply
#5

Its exactly the same what we showed him.:
pawn Код:
stock ProxDetector(Float:radi, playerid, string[],color)
{
    new Float:x,Float:y,Float:z;
    GetPlayerPos(playerid,x,y,z);
    for(new player;player<MAX_PLAYERS;player++)
    {
        if(!IsPlayerConnected(playerid))continue;
        if(IsPlayerInRangeOfPoint(playerid,radi,x,y,z))SendClientMessage(player,color,string);
    }
}
Reply
#6

Thank you, man!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)