Help with IsPlayerInArea
#1

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
Reply
#2

Show the parameters of IsPlayerInArea
Reply
#3

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.
Reply
#4

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;
}
Reply
#5

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

it still does not disarm the player
Reply
#7

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);
    }
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)