IsPlayerInArea Doesnt work
#1

Hey scripters
I got this stupid problem
that my IsPlayerInArea doesnt work.
Okey so here is the stock

pawn Код:
stock IsPlayerInArea(playerid,Float:min_x,Float:min_y,Float:max_x,Float:max_y)
{
 new Float: p[3];
 GetPlayerPos(playerid,p[0],p[1],p[2]);
 return p[0] >= min_x && p[0] <= max_x && p[1] >= min_y && p[1] <= max_y? 1:0;
}
Okey so it supouse to be min_x,max_y,max_x,min_y:

Right ?

Okey I got this

pawn Код:
public OnPlayerUpdate(playerid)
{
    if(IsPlayerInArea(playerid,2317.1729,-0.1240,2304.8511,-17.3021))
    {
        Kick(playerid);
              }
    return 0;
}
it supouse to kick the player if he is in the bank.

no errors,but when I am there it doesnt kick me .
Reply
#2

Dude i just checked wiki and it says this

IsPlayerInArea
(playerid, Float:minx, Float:maxx, Float:miny, Float:maxy)
Reply
#3

There are different versions of IsPlayerInArea

The important thing is that you put the right coords at the right place in your IsPlayerInArea

And guys I suggest you to use IsPlayerInRangeOfPoint because IsPlayerInArea can only create squares along the axes

That would be an advanced version of IsPlayerInArea which supports more areas
So you arent restricted to one big but still a native like IsPlayerInRangeOfPoint would be faster

pawn Код:
stock IsPlayerInArea(playerid, Float: ...)
{ //Nero_3D: Supports more areas! (min_x, max_x, min_y, max_y)
    new
        Float: Pos[2];
    if(GetPlayerPos(playerid, Pos[0], Pos[1], (Float: playerid))) {
        for(playerid = (numargs() - ((numargs() - 1) % 4) - 1); playerid != 0; playerid -= 4) {
            if( (Float: getarg(playerid - 3)) <= Pos[0] <= (Float: getarg(playerid - 2)) &&
                (Float: getarg(playerid - 1)) <= Pos[1] <= (Float: getarg(playerid)) ) {
                    return true;
            }
        }
    }
    return false;
}
But your main problem is that min_x is bigger than max_x

min_x = 2317.1729
min_y = -17.3021
max_x = 2304.8511
max_y = -0.1240

That would be correct for you: 2304.8511, -17.3021, 2317.1729, -0.1240
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)