Player is in range of player
#1

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?
Reply
#2

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

You only need GetPlayerPos for one of the players.
Reply
#4

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 */ }
Reply
#5

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

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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)