SA-MP Forums Archive
Help with IsPlayerInArea - 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: Help with IsPlayerInArea (/showthread.php?tid=546995)



Help with IsPlayerInArea - LeXuZ - 19.11.2014

Hello, I have been working on a SafeZone, and i wanted it so when you walked into the SafeZone it would disarm you, i've made this
Код:
public OnPlayerUpdate(playerid)
{
    IsPlayerInArea(playerid, 2972.0000, 581.7188, 676.0000, 2930.0000);
 	{
    new Float:X, Float:Y, Float:Z;
    GetPlayerPos(playerid, X, Y, Z);
    if(X >= 2972.0000 && X <= 581.7188 && Y >= 676.0000 && Y <= 2930.0000)
	{
 	ResetPlayerWeapons(playerid);
 	return 1;
    }
	}
	return 1;
}
but when i enter the safezone i still have my guns... can someone help me please


Re : Help with IsPlayerInArea - Dutheil - 19.11.2014

Show the parameters of IsPlayerInArea


Re: Help with IsPlayerInArea - Fel486 - 19.11.2014

Try:

pawn Код:
public OnPlayerUpdate(playerid)
{
    if(IsPlayerInArea(playerid, 2972.0000, 581.7188, 676.0000, 2930.0000))
    {
        new Float:X, Float:Y, Float:Z;
        GetPlayerPos(playerid, X, Y, Z);
        if(X >= 2972.0000 && X <= 581.7188 && Y >= 676.0000 && Y <= 2930.0000)
        {
            ResetPlayerWeapons(playerid);
       
        }
    }
    return 1;
}
Also check if coordinates are correct.


Re: Help with IsPlayerInArea - LeXuZ - 19.11.2014

I'll show you the codes i am using to make it work
Код:
SafeZone = GangZoneCreate(2972.0000, 581.7188, 676.0000, 2930.0000);
Код:
stock IsPlayerInArea(playerid,Float:max_x,Float:min_x,Float:max_y,Float:min_y)
{
new Float:X;
new Float:Y;
new Float:Z;
GetPlayerPos(playerid, X, Y, Z);
if(X <= max_x && X >= min_x && Y <= max_y && Y >= min_y)
{
return 1;
}
return 0;
}



Re : Help with IsPlayerInArea - Dutheil - 19.11.2014

Try this, I reversed the last two parameters
pawn Код:
IsPlayerInArea(playerid, 2972.0000, 581.7188, 2930.0000, 676.0000);



Re: Help with IsPlayerInArea - LeXuZ - 19.11.2014

it still does not disarm the player


AW: Help with IsPlayerInArea - Nero_3D - 19.11.2014

It is GangZoneCreate(Float:minx, Float:miny, Float:maxx, Float:maxy) so it should be
pawn Код:
SafeZone = GangZoneCreate(581.7188, 676.0, 2972.0, 2930.0);
For easier usage you should always use the same syntax
pawn Код:
IsPlayerInArea(playerid, Float: minx, Float: miny, Float: maxx, Float: maxy) {
    new
        Float: X,
        Float: Y
    ; // a little optimisation
    return GetPlayerPos(playerid, X, Y, Float: playerid) && (minx <= X <= maxx) && (miny <= Y <= maxy);
}
And now OnPlayerUpdate
pawn Код:
//OnPlayerUpdate
    if(IsPlayerInArea(playerid, 581.7188, 676.0, 2972.0, 2930.0)) {
        ResetPlayerWeapons(playerid);
    }