SA-MP Forums Archive
IsPlayerInRangeOfPoint alternative - 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: IsPlayerInRangeOfPoint alternative (/showthread.php?tid=527866)



IsPlayerInRangeOfPoint alternative - NeroX98 - 24.07.2014

Hi,
I need a function that checks only X and Y without Z... IsPlayerInRangeOfPoint needs Z coordinate and i just want to see if the player is in range of the x and y coordinate ?


Re: IsPlayerInRangeOfPoint alternative - David (Sabljak) - 24.07.2014

Код:
stock IsPlayerInTheArea(playerid,Float:minx,Float:miny,Float:maxx,Float:maxy)
{
	new Float:p[3];
	GetPlayerPos(playerid, p[0],p[1],p[2]);
	if(p[0] >= minx && p[0] <= maxx && p[1] >= miny && p[1] <= maxy)
	{
	    return true;
	}
	else return false;
}



Re: IsPlayerInRangeOfPoint alternative - IstuntmanI - 24.07.2014

pawn Код:
stock IsPlayerInRangeOf2DPoint( playerid, Float:range, Float:px, Float:py )
{
    new Float:lfPos[ 3 ];
    GetPlayerPos( playerid, lfPos[ 0 ], lfPos[ 1 ], lfPos[ 2 ] );
    return ( VectorSize( px - lfPos[ 0 ], py - lfPos[ 1 ], 0.0 ) < range );
}
I hope it works.


Re: IsPlayerInRangeOfPoint alternative - d3ll - 24.07.2014

pawn Код:
stock IsPlayerInRangeOfPointEx(playerid, Float:iX, Float:iY, Float:iSze)
{
    new Float:pX, Float:pY, Float:pZ;
   
    GetPlayerPos(playerid, pX, pY, pZ);
   
    #pragma unused pZ
   
    new Float:XEx = (pX - iSze), Float:YEx = (pY - iSze),
        Float:XExx = (pX + iSze), Float:YExx = (pY + iSze);
       
    if(iX >= XEx && iX <= XExx)
    {
        if(iY >= YEx && iY <= YExx)
        {
            return 1;
        }
    }
    return 0;
}
Tested, works.


Re: IsPlayerInRangeOfPoint alternative - NeroX98 - 24.07.2014

Thank you bro... You helped me so much !

REP +!