which one? -
Gh0sT_ - 02.09.2011
Which one is better at performance? (Sorry for bad indentation, I wrote these codes in this box
![Cheesy](images/smilies/biggrin.png)
)
pawn Код:
new Float:Array[][] =
{
{X, Y, Z},
{X, Y, Z},
{X, Y, Z}
};
stock IsPlayerNearSomething(playerid)
{
for(new i; i != sizeof(Array); ++i)
{
return IsPlayerInRangeOfPoint(playerid, radius, Array[i][0], Array[i][1], Array[i][2]);
}
}
OR just
pawn Код:
stock IsPlayerNearSomething(playerid)
{
if(IsPlayerInRangeOfPoint(playerid, radius, X, Y, Z) || IsPlayerInRangeOfPoint(playerid, radius, X, Y, Z) || IsPlayerInRangeOfPoint(playerid, radius, X, Y, Z)) return true;
return false;
}
And, one question: Can I create stocks like this?
stock IsPlayerNearSomething(playerid)
{
return IsPlayerInRangeOfPoint(playerid, radius, X, Y, Z) || IsPlayerInRangeOfPoint(playerid, radius, X, Y, Z) || IsPlayerInRangeOfPoint(playerid, radius, X, Y, Z);
}
Re: which one? -
FireCat - 02.09.2011
I think they are both basicly the same.
Re: which one? -
Gh0sT_ - 02.09.2011
And what about my question?
Re: which one? -
[MWR]Blood - 02.09.2011
You could do:
pawn Код:
stock IsPlayerNearSomething(playerid)
{
if(IsPlayerInRangeOfPoint(playerid, radius, X, Y, Z) return 1;
if(IsPlayerInRangeOfPoint(playerid, radius, x, y, z) return 1;
return 0;
}
If you do it all in a row, you could encounter some errors as you might exceed the maximum PAWN length.
Re: which one? -
Pinguinn - 02.09.2011
The arrays are more easier to use
What I am showing below does the same thing as [MWR]Blood posted
It returns false if he is not near it, and returns true if he is
pawn Код:
new Float:Array[][] =
{
{X, Y, Z},
{X, Y, Z},
{X, Y, Z}
};
stock IsPlayerNearSomething(playerid)
{
for(new i; i != sizeof(Array); ++i)
{
if(IsPlayerInRangeOfPoint(playerid, radius, Array[i][0], Array[i][1], Array[i][2]) return true;
}
return false;
}
Re: which one? -
Gh0sT_ - 02.09.2011
And what about my question? ..
Re: which one? -
Zonoya - 02.09.2011
the top one is best he is saying dude