Custom IsPlayerInRangeOfPoint
#1

Hello.
I've founded in some script this function:

pawn Код:
stock PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
    if(IsPlayerConnected(playerid))
    {
        new Float:oldposx, Float:oldposy, Float:oldposz;
        new Float:tempposx, Float:tempposy, Float:tempposz;
        GetPlayerPos(playerid, oldposx, oldposy, oldposz);
        tempposx = (oldposx -x);
        tempposy = (oldposy -y);
        tempposz = (oldposz -z);
        if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
        {
            return 1;
        }
    }
    return 0;
}
It seems that it's the same as IsPlayerInRangeOfPoint.
So, is there any point of using this custom function, or it's really stupid? (I think it is.)

Sorry for my English.
Reply
#2

pawn Код:
PlayerToPoint(Float:radius, playerid, Float:X, Float:Y, Float:Z)
{
    new Float:oldpos[3], Float:temppos[3];
    GetPlayerPos(playerid, oldpos[0], oldpos[1], oldpos[2]);
    temppos[0] = (oldpos[0] -X);
    temppos[1] = (oldpos[1] -Y);
    temppos[2] = (oldpos[2] -Z);
    if(((temppos[0] < radius) && (temppos[0] > -radius)) && ((temppos[1] < radius) && (temppos[1] > -radius)) && ((temppos[2] < radius) && (temppos[2] > -radius)))
    {
        return true;
    }
    return false;
//=============
if(PlayerToPoint(10.0, playerid, x,y,z))
Or...
pawn Код:
if(IsPlayerInRangeOfPoint(playerid , range, x,y,z))
Reply
#3

Quote:
Originally Posted by Anuris
Посмотреть сообщение
So, is there any point of using this custom function
No. The function IsPlayerInRangeOfPoint was only added in SA-MP 0.3a; people used the function mentioned above to fill in this void in earlier versions.
Reply
#4

But it's woold be betther, if I change it to IsPlayerInRangeOfPoint? Faster, for example?
Reply
#5

Native functions are always faster than custom functions, yes.
Reply
#6

Thank you.
Reply
#7

Quote:
Originally Posted by Vince
Посмотреть сообщение
No. The function IsPlayerInRangeOfPoint was only added in SA-MP 0.3a; people used the function mentioned above to fill in this void in earlier versions.
is there any similair function to use in 0.3x ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)