How to detect if a player is in range of another player?
#5

Okay, so you could make a stock for this if you want to do it like this:

Код:
stock IsPlayerInRangeOfPlayer(playerid, Float: range, player2)
{
if(!IsPlayerConnected(player2)) return 0;
new Float: x, Float: y, Float: z;
GetPlayerPos(playerid, x, y, z);
if(IsPlayerInRangeOfPoint(player2, range, x, y, z) return 1;
else if(!IsPlayerInRangeOfPoint(player2, range, x, y, z) return 0;
}
So what it does is use x, y, z to detect the first player's position. Then if they are in range of that position you'll return 1 if not just return 0.

An example of how you can use this is:

Detecting if they ARE in range: if(IsPlayerInRangeOfPlayer(playerid, 25.0, player2);
if they're not... if(!IsPlayerInRangeOfPlayer... Bla bla bla

Hope I explained this throughly enough!
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)