Need Some Info - 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: Need Some Info (
/showthread.php?tid=303516)
Need Some Info -
titanak - 13.12.2011
Hi! i need some info about IsPlayerInArea..
function:
pawn Код:
IsPlayerInArea(playerid, Float:minx, Float:maxx, Float:miny, Float:maxy)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
if (x > minx && x < maxx && y > miny && y < maxy) return 1;
return 0;
}
i am using:
pawn Код:
if(IsPlayerInArea(playerid, -2398.550048, 1890.259765, -2182.550048, 2122.259765))
{
return 1;
}
if(!IsPlayerInArea(playerid, -2398.550048, 1890.259765, -2182.550048, 2122.259765)) // <------
{
return 0;
}
But the !IsPlayerInArea doesn't work , it still shows the message if i am not anymore in this area. what to do??
or when i use:
pawn Код:
if(IsPlayerInArea(playerid, -2398.550048, 1890.259765, -2182.550048, 2122.259765)) // <------
{
return 1;
}
else
{
return 0;
}
please help , reping too.
Re: Need Some Info -
Rob_Maate - 13.12.2011
I wrote a stock up quickly, use this inplace of whatever your current one is.
Your function was broken because of the ordering of inputs.
When you have a set of coords, it comes in two pairs, X and Y.
You were specifying MinX and MaxX together, meaning the area was physically appearing somewhere you didn't expect it to
pawn Код:
stock IsPlayerInArea(playerid, Float:MinX, Float:MinY, Float:MaxX, Float:MaxY)
{
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
if (X > MinX && X < MaxX && Y > MinY && Y < MaxY)
{
return true;
}
else
{
return false;
}
}