09.04.2013, 14:18
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?
Any advice? Possibly a solution?
new Float:x, Float:y, Float:z;
GetPlayerPos(pID, x, y, z);
if(IsPlayerInRangeOfPoint(playerid, 10, x, y, z)) { /* do your things here */ }
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;
}