SA-MP Forums Archive
Player is in range of player - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Player is in range of player (/showthread.php?tid=429385)



Player is in range of player - thistooshallpass93 - 09.04.2013

I am making a /cuff command and I'm not sure how to check if a player is in range of another player.

Any advice? Possibly a solution?


Re: Player is in range of player - MattyG - 09.04.2013

Try using GetPlayerPos on both the players, then use IsPlayerInRangeOfPoint to check the distance.


Re: Player is in range of player - MP2 - 09.04.2013

You only need GetPlayerPos for one of the players.


Re: Player is in range of player - Da_Noob - 09.04.2013

Try this

pawn Код:
new Float:x, Float:y, Float:z;
GetPlayerPos(pID, x, y, z);
if(IsPlayerInRangeOfPoint(playerid, 10, x, y, z)) { /* do your things here */ }



Re: Player is in range of player - Riddick94 - 09.04.2013

http://forum.sa-mp.com/showpost.php?...6&postcount=13


Re: Player is in range of player - Konstantinos - 09.04.2013

Not sure how you want it, but an example!
pawn Код:
CMD:cuff(playerid, params[])
{
    new
        id,
        id2
    ;
    if(sscanf(params, "uu", id, id2)) return SendClientMessage(playerid, -1, "Usage: /cuff <playerid1> <playerid2>");
    if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "Player A is not connected");
    if(id2 == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "Player B is not connected");
    new
        Float: pos[ 3 ]
    ;
    GetPlayerPos(id2, pos[ 0 ], pos[ 1 ], pos[ 2 ]);
    if(IsPlayerInRangeOfPoint(id, 5.0, pos[ 0 ], pos[ 1 ], pos[ 2 ]))
    SendClientMessage(playerid, -1, "Player A is in range of player B!");
    return 1;
}