IsPlayerInArea - bugged
#1

I've got this function:
pawn Код:
public IsPlayerInArea(playerid, Float:maxx, Float:minx, Float:maxy, Float:miny)
{
    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;
}
And i tryed to take the coordinates for the red square



In the upper left corner, i typed /save and i got:
[b]-15.4505, -6.0218[/[b]
x_min = -15.4505
y_max = -6.0218

In the down right corner, i typed /save and i got:
30.1200,5.7569
x_max = 30.1200
y_min = 5.7569

and at OnPlayerUpdate, i've added:
pawn Код:
if(IsPlayerInArea(playerid,30.1200, -15.4505, -6.0218, 5.7569))
       printf("%d is in area",playerid);
And i don't get any client message ...
Reply
#2

Switch min and max y (the last two params).

[This forum requires that you wait 120 seconds between posts. Please try again in 16 seconds.] Go away!
Reply
#3

nop, is not so good ... is not right that size ... it's something like that ...
Reply
#4

y_max = -6.0218
y_min = 5.7569

You need to change those

y_min = -6.0218
y_max = 5.7569
Reply
#5

So the function will look like this, right ?

if(IsPlayerInArea(playerid,30.1200, -15.4505, 5.7569, -6.0218 ))
Reply
#6

Its the opposite of what you have.
Its:
MinX and MinY are the first corner,
then:
MaX and MaxY are the 2nd corner.
Reply
#7

if(IsPlayerInArea(playerid,-15.4505, 30.1200, -6.0218, 5.7569 ))

If the number is -blabla then have 30.blabla negative numbers are not greater than positive numbers, try that.
Reply
#8

Ok, this is working 50% if(IsPlayerInArea(playerid,30.1200, -15.4505, 5.7569, -6.0218 )) ...

this if(IsPlayerInArea(playerid,-15.4505, 30.1200, -6.0218, 5.7569 )) is not working


Quote:
Originally Posted by The Toni
Посмотреть сообщение
Its the opposite of what you have.
Its:
MinX and MinY are the first corner,
then:
MaX and MaxY are the 2nd corner.

That's not true ... doesn't work ... make the IsPlayerInArea function with coordinates to see ...
Reply
#9

Quote:
Originally Posted by MJ!
Посмотреть сообщение
Ok, this is working 50% if(IsPlayerInArea(playerid,30.1200, -15.4505, 5.7569, -6.0218 )) ...
Why only 50%? It should work 100%
Reply
#10

I don't know, it works like a small rectangle on diagonal ...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)