Check if player is in area.
#1

Hello. I have this bug now,I hope any of you can help.
Please read carefully the codes and comments..

pawn Код:
// Upon all, we define.
new Forbidzone1, Forbidzone2, Forbidzone3, Forbidzone4, Forbidzone5;
pawn Код:
// Create 5 gangzones that represent 5 forbid zones where the players cant go.
// In Game, the gangzones looks goods, glitchless.
    Forbidzone1 = GangZoneCreate(-864.1628, -4087.256, 4063.901, 2989.536);
    Forbidzone2 = GangZoneCreate(-2977.858, 2627.522, 2837.724, 2977.858);
    Forbidzone3 = GangZoneCreate(-2989.536, -3316.517, -2662.556, 2989.536);
    Forbidzone4 = GangZoneCreate(-2966.18, -3012.892, 3082.959, 58.38938);
    Forbidzone5 = GangZoneCreate(-2989.536, -3188.06, -1996.917, 934.23);
pawn Код:
// This makes when the player updates it will call the un-native callback "IsPlayerInArea()"
public OnPlayerUpdate(playerid)
{
      ...
      IsPlayerInArea();
      ...
      return 1;
}
pawn Код:
// This constantly gets the X,Y,Z coordenates and checks if the player is in between a range (used to check if the player is INSIDE the gangzone)

forward IsPlayerInArea()
public IsPlayerInArea()
{
    for(new i=0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            new Float:x, Float:y, Float:z;
            GetPlayerPos(i, x, y, z);
            if (x > -864 && x < -4087 && y > 4063 && y < 2989)
            {
                SendClientMessage(i,COLOR_WHITE,"Your in the area lol");
            }
            else if (x > -2977 && x < 2627 && y > 2837 && y < 2977)
            {
                SendClientMessage(i,COLOR_WHITE,"Your in the area lol");
            }
            else if (x > -2989 && x < -3316 && y > -2662 && y < 2989)
            {
                SendClientMessage(i,COLOR_WHITE,"Your in the area lol");
            }
            else if (x > -2966 && x < -3012 && y > 3082 && y < 58)
            {
                SendClientMessage(i,COLOR_WHITE,"Your in the area lol");
            }
            else if (x > -2989 && x < -3188 && y > -1996 && y < 934)
            {
                SendClientMessage(i,COLOR_WHITE,"Your in the area lol");
            }
        }
    }
}
Ok, so what's my problem? I go in the area, and nothing. Yes, NOTHING happens.
Any helps is appreciated
Reply
#2

// Red Zone
redzone = GangZoneCreate(-2135.883, -542.088, -1958.199, -368.5095);
// Red Zone

new Float, Float:y, Float:z;
GetPlayerPos(i, x, y, z);
if(x >= -2135.883 && x < -1958.199 && y >= -542.088 && y < -368.5095)
{
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)