Function bug - 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: Function bug (
/showthread.php?tid=243005)
Function bug - Unknown123 - 21.03.2011
It is just not working
pawn Код:
stock IsPlayerInArea(playerid, Float:X1, Float:Y2, Float:X3, Float:Y4)
{
new Float:pX, Float:pY, Float:pZ;
GetPlayerPos(playerid, pX, pY, pZ);
if(pX >= X1 && pX <= X3 && pY >= Y2 && pY <= Y4)
return true;
else
return false;
}
I took the coords on this way:
--------(North)
Re: Function bug -
s0nic - 21.03.2011
I don't think I've ever seen that one..
I use this one and it works fine:
pawn Код:
IsPlayerInArea(playerid, Float:X1, Float:X2, Float:Y1, Float:Y2)
{
new Float:X, Float:Y, Float:Z;
if(X1 > X2) { X = X2; X2 = X1; X1 = X; }
if(Y1 > Y1) { Y = Y2; Y2 = Y1; Y1 = Y; }
GetPlayerPos(playerid, X, Y, Z);
if((X1 < X && X < X2) && (Y1 < Y && Y < Y2)) return 1;
return 0;
}
Re: Function bug -
MadeMan - 21.03.2011
area.JPG
You need to take coords from 2 places only (red dots on picture)
And then the code would be:
pawn Код:
stock IsPlayerInArea(playerid, Float:minX, Float:minY, Float:maxX, Float:maxY)
{
new Float:pX, Float:pY, Float:pZ;
GetPlayerPos(playerid, pX, pY, pZ);
if(pX >= minX && pX <= maxX && pY >= minY && pY <= maxY)
return true;
else
return false;
}