SA-MP Forums Archive
How to stock ( IfPlayerIsInRangeOfPlayer ) - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: How to stock ( IfPlayerIsInRangeOfPlayer ) (/showthread.php?tid=264423)



How to stock ( IfPlayerIsInRangeOfPlayer ) - CosmicHosting - 26.06.2011

Basically the stock of what I said , It should work while in a vehicle too

_

Proud sponsor of Cosmic hosting and DMCA


Re: How to stock ( IfPlayerIsInRangeOfPlayer ) - [HiC]TheKiller - 26.06.2011

You could use GetDistanceBetweenPlayers
pawn Код:
stock Float:GetDistanceBetweenPlayers(player1, player2)
{
    new Float:X, Float:Y, Float:Z, Float:PointX, Float:PointY, Float:PointZ;
    GetPlayerPos(player1, X, Y, Z);
    GetPlayerPos(player2, PointX, PointY, PointZ);
    return floatsqroot(floatpower(floatsub(X, PointX), 2.0) + floatpower(floatsub(Y, PointY), 2.0) + floatpower(floatsub(Z, PointZ), 2.0));
}
Then do this:

pawn Код:
if(GetDistanceBetweenPlayers(player1, player2) <= /*Range*/)
{
    //Player is in range
}



Re: How to stock ( IfPlayerIsInRangeOfPlayer ) - [L3th4l] - 26.06.2011

You can use the "IsPlayerInRangeofPoint" function:

pawn Код:
stock PlayerIsInRangeOfPlayer(playerid, otherid, Float:range)
{
    new
        Float: iPos[3];

    GetPlayerPos(otherid, iPos[0], iPos[1], iPos[2]);

    return IsPlayerInRangeOfPoint(playerid, range, iPos[0], iPos[1]);
}