[Help] isPlayerinArea
#1

Hi all

I'm using this https://sampwiki.blast.hk/wiki/Areacheck

Код:
   public isPlayerInArea()
   {
       new Float:X, Float:Y, Float:Z; //We use this to store player position
       for(new i=0; i < MAX_PLAYERS; i++) //This line defines a name for all player, the name is "i"
       {
           GetPlayerPos(i, X, Y, Z); //Here we are storing the player position on the variables X, Y, and Z defined previously
           if (X <= -3915 && X >= -3694 && Y <= 401 && Y >= 37)
           /* This line is the important one!. Here, is where you change those numbers, by the ones
           you get from the /pos command. As you can see, those coordinates, are only the X and Y ones, the Z
           doesnt matter*/
           {
               SetPlayerHealth(i, -999999.9); //This will ensure, that our player gets killed if he tries to enter
           }
       }
   }
I want it should work only if a player is gWanted how can i make it ? Now it kills all if he/she enters the area
Reply
#2

Did you set the timer as they said in wiki?
Reply
#3

yes all... Now it should kill everyone if they enter the area (didn't tested but i want it should only kill if player is wanted "gWanted"
Reply
#4

Oh, that's what you meant, my bad then and here you go, change the old isPlayerInArea to this.
pawn Код:
public isPlayerInArea() {
    New Float:X, Float:Y, Float:Z;
    For(new i=0; i < MAX_PLAYERS; i++) {
        GetPlayerPos(i, X, Y, Z);
        if (X <= -3915 && X >= -3694 && Y <= 401 && Y >= 37 && gWanted[playerid] == 1) SetPlayerHealth(i, -999999.9);
    }
}
Reply
#5

No need here return ? :/
pawn Код:
if (X <= -3915 && X >= -3694 && Y <= 401 && Y >= 37 && gWanted[playerid] == 1) return SetPlayerHealth(i, -999999.9);
sorry if im wrong im just asking...
Reply
#6

No, because it won't return anything under this if, so it doesn't matter actually.
Reply
#7

pawn Код:
if (X <= -3915 && X >= -3694 && Y <= 401 && Y >= 37 && PlayerInfo[i][gWanted])

Quote:
Originally Posted by EliranPesahov
Посмотреть сообщение
if (X <= -3915 && X >= -3694 && Y <= 401 && Y >= 37 && gWanted[playerid] == 1) SetPlayerHealth(i, -999999.9);[/pawn]
I'm sure he uses gWanted as the numbers of his wanted stars, so that will only work if he is only one star wanted.
Reply
#8

Quote:
Originally Posted by Adil
Посмотреть сообщение
I'm sure he uses gWanted as the numbers of his wanted stars
You didn't.
Reply
#9

thanks all but i didnt worked.. So i tested the code from wikipedia

Код:
   public isPlayerInArea()
   {
       new Float:X, Float:Y, Float:Z; //We use this to store player position
       for(new i=0; i < MAX_PLAYERS; i++) //This line defines a name for all player, the name is "i"
       {
           GetPlayerPos(i, X, Y, Z); //Here we are storing the player position on the variables X, Y, and Z defined previously
           if (X <= -3915 && X >= -3694 && Y <= 401 && Y >= 37)
           /* This line is the important one!. Here, is where you change those numbers, by the ones
           you get from the /pos command. As you can see, those coordinates, are only the X and Y ones, the Z
           doesnt matter*/
           {
               SetPlayerHealth(i, -999999.9); //This will ensure, that our player gets killed if he tries to enter
           }
       }
   }
and saw this dont works too....
Reply
#10

Quote:
Originally Posted by Adil
Посмотреть сообщение
You didn't.
I did, you meant... with how much stars the player owns, but actually it doesn't matter know, he says it doesn't work.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)