is player in area
#1

hey there i need help iv got this code


Код:
public isPlayerInArea(playerid)
  {
    new Float:X, Float:Y, Float:Z; 
    for(new i=0; i < MAX_PLAYERS; i++) 
    {
      GetPlayerPos(i, X, Y, Z); 
      if (X <= 1543 && X >= 1608 && Y <= -1634 && Y >= -1602)
      {
        if (gTeam[playerid] == TEAM_CIVILLIAN)
				{
			  GameTextForPlayer(playerid,"~y~ You Died For Being On Police Property",5000,5);
			  SetPlayerHealth(i, -999999.9); //This will ensure, that our player gets killed if he tries to enter
			}
		  }
    }
  }
but it dosent kill civillian and i whant it to kill civillian


thx for ur time
Reply
#2

pawn Код:
forward PlayerInAreaCheck();
pubic PlayerInAreaCheck()
{
  for(new i = 0, i < MAX_PLAYERS; i++)
  {
    if(IsPlayerInArea(i, 1543, 1608, -1634, -1602))
    {
      if(gTeam[i] == TEAM_CIVILIAN)
      {
        GameTextForPlayer(playerid,"~y~ You Died For Being On Police Property",5000,5);
        SetPlayerHealth(i, -999999.9);
      }
    }
  }
  return 1;
}

OnGameModeInIt()
{
  SetTimer("PlayerInAreaCheck", 1000, 1);
  return 1;
}
At the bottom of your script
pawn Код:
stock IsPlayerInArea(playerid, Float:max_x, Float:min_x, Float:max_y, Float:min_y)
{
    new Float:X, Float:Y, 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
#3

got one error


C:\Program Files\Rockstar Games\GTA San Andreas\samp sever\gamemodes\cops&robbers.pwn(443) : error 021: symbol already defined: "i"
Reply
#4

pawn Код:
forward PlayerInAreaCheck();
pubic PlayerInAreaCheck()
{
  for(new i = 0, i < MAX_PLAYERS; i++)
  {
    if(IsPlayerInArea(i, 1543, 1608, -1634, -1602))
    {
      if(gTeam[i] == TEAM_CIVILIAN)
      {
        GameTextForPlayer(i,"~y~ You Died For Being On Police Property",5000,5);
        SetPlayerHealth(i, -999999.9);
      }
    }
  }
  return 1;
}

OnGameModeInIt()
{
  SetTimer("PlayerInAreaCheck", 1000, 1);
  return 1;
}
At the bottom of your script
pawn Код:
stock IsPlayerInArea(playerid, Float:max_x, Float:min_x, Float:max_y, Float:min_y)
{
    new Float:X, Float:Y, Float:Z;
    GetPlayerPos(playerid, X, Y, Z);
    if(X <= max_x && X >= min_x && Y <= max_y && Y >= min_y) return 1;
    return 0;
}
try that
Reply
#5

Quote:
Originally Posted by Gappy
pawn Код:
forward PlayerInAreaCheck();
pubic PlayerInAreaCheck()
{
  for(new i = 0, i < MAX_PLAYERS; i++)
  {
    if(IsPlayerInArea(i, 1543, 1608, -1634, -1602))
    {
      if(gTeam[i] == TEAM_CIVILIAN)
      {
        GameTextForPlayer(i,"~y~ You Died For Being On Police Property",5000,5);
        SetPlayerHealth(i, -999999.9);
      }
    }
  }
  return 1;
}

OnGameModeInIt()
{
  SetTimer("PlayerInAreaCheck", 1000, 1);
  return 1;
}
At the bottom of your script
pawn Код:
stock IsPlayerInArea(playerid, Float:max_x, Float:min_x, Float:max_y, Float:min_y)
{
    new Float:X, Float:Y, Float:Z;
    GetPlayerPos(playerid, X, Y, Z);
    if(X <= max_x && X >= min_x && Y <= max_y && Y >= min_y) return 1;
    return 0;
}
try that
You better learn to script before misleading other people.
Reply
#6

Why? What's wrong with it? 0.o

Apart from the fact I wrote pubic instead of public. and forgot public in OnGameModeInIt

I wrote it in a rush.
Reply
#7

pawn Код:
forward PlayerInAreaCheck(playerid);
pubic PlayerInAreaCheck(playerid)
{
  for(new i = 0, max = GetMaxPlayers(); i < max; i++)
  {
    if(!IsPlayerConnected(playerid)) continue;
    if(IsPlayerInArea(i, 1543, 1608, -1634, -1602))
    {
      if(gTeam[i] == TEAM_CIVILIAN)
      {
        GameTextForPlayer(playerid,"~y~ You Died For Being On Police Property",5000,5);
        SetPlayerHealth(i, -999999.9);
      }
    }
  }
  return 1;
}

public OnPlayerConnect(playerid)
{
  SetTimer("PlayerInAreaCheck", 1000, 1, "i", playerid);
  return 1;
}
Reply
#8

Quote:
Originally Posted by dice7
pawn Код:
forward PlayerInAreaCheck(playerid);
pubic PlayerInAreaCheck(playerid)
{
  for(new i = 0, i < MAX_PLAYERS; i++)
  {
    if(!IsPlayerConnected(playerid)) continue;
    if(IsPlayerInArea(i, 1543, 1608, -1634, -1602))
    {
      if(gTeam[i] == TEAM_CIVILIAN)
      {
        GameTextForPlayer(playerid,"~y~ You Died For Being On Police Property",5000,5);
        SetPlayerHealth(i, -999999.9);
      }
    }
  }
  return 1;
}

OnPlayerConnect(playerid)
{
  SetTimerEx("PlayerInAreaCheck", 1000, 1, "i", playerid);
  return 1;
}
Why would you need to set a new timer for every player when PlayerInAreaCheck already loops through everyone to check if they are in the area?
Reply
#9

woops
pawn Код:
forward PlayerInAreaCheck(playerid);
pubic PlayerInAreaCheck(playerid)
{
  for(new i = 0, max = GetMaxPlayers(); i < max; i++)
  {
    if(!IsPlayerConnected(i)) continue;
    if(IsPlayerInArea(i, 1543, 1608, -1634, -1602))
    {
      if(gTeam[i] == TEAM_CIVILIAN)
      {
        GameTextForPlayer(i,"~y~ You Died For Being On Police Property",5000,5);
        SetPlayerHealth(i, 0.0);
      }
    }
  }
  return 1;
}

public OnGameModeInit()
{
  SetTimer("PlayerInAreaCheck", 1000, 1);
  return 1;
}
Edit: I know my mistakes, I just copied the above code and changed the timer, but I then saw a few errors
Reply
#10

Quote:
Originally Posted by Gappy
Why? What's wrong with it? 0.o

Apart from the fact I wrote pubic instead of public. and forgot public in OnGameModeInIt

I wrote it in a rush.
Wrote it in a rush? Your lies won't get you far.. You didn't even write this code..

Stay away from this topic please, you just lie and mislead him.



Dice, pay attention to what you're doing. You're having mistakes with playerid and i (the loop)
forward PlayerInAreaCheck(playerid);
pawn Код:
pubic PlayerInAreaCheck(playerid)
{
  for(new i = 0, i < MAX_PLAYERS; i++) // here, PlayerInAreaCheck is supposed to be for playerid, so why would you make a loop?
  {
    if(!IsPlayerConnected(playerid)) continue;
    if(IsPlayerInArea(i, 1543, 1608, -1634, -1602))
    {
      if(gTeam[i] == TEAM_CIVILIAN)
      {
        GameTextForPlayer(playerid,"~y~ You Died For Being On Police Property",5000,5);
        SetPlayerHealth(i, -999999.9);
      }
    }
  }
  return 1;
}
Reply
#11

Quote:
Originally Posted by MenaceX^
Quote:
Originally Posted by Gappy
Why? What's wrong with it? 0.o

Apart from the fact I wrote pubic instead of public. and forgot public in OnGameModeInIt

I wrote it in a rush.
Wrote it in a rush? Your lies won't get you far.. You didn't even write this code..

Stay away from this topic please, you just lie and mislead him.
Woah that is a big accusation, I 100% wrote the code I posted, I'm sorry for trying to help people.
Reply
#12

Oh'rly? How comes that this code is released around and was made by someone else before you copied and claimed it as you made it?..
Cmon, you don't really help here. You just try to get yourself known by copying codes or something..
Reply
#13

Quote:
Originally Posted by MenaceX^
Oh'rly? How comes that this code is released around and was made by someone else before you copied and claimed it as you made it?..
Cmon, you don't really help here. You just try to get yourself known by copying codes or something..
I didn't made the IsPlayerInArea but I seriously made the PlayerInAreaCheck code just then, maybe the "PlayerInAreaCheck" name has been used before but I'm 100% serious and I'm sticking to my story, I just wrote that code in a rush before.

I don't want to start a flame war here and you seem like a nice guy, but I hate when I get told by a guy that I've never talked to before that I copied someone elses code, claimed that I wrote it and saying that I'm just trying to get my name out there.
Reply
#14

Interesting, as you keep lying
This is what you posted
pawn Код:
stock IsPlayerInArea(playerid, Float:max_x, Float:min_x, Float:max_y, Float:min_y)
{
    new Float:X, Float:Y, Float:Z;
    GetPlayerPos(playerid, X, Y, Z);
    if(X <= max_x && X >= min_x && Y <= max_y && Y >= min_y) return 1;
    return 0;
}
apparently "your" code name is IsPlayerInArea, and not PlayerInAreaCheck as you say, you are just contradictory yourself.
Reply
#15

Quote:
Originally Posted by MenaceX^
Interesting, as you keep lying
This is what you posted
pawn Код:
stock IsPlayerInArea(playerid, Float:max_x, Float:min_x, Float:max_y, Float:min_y)
{
    new Float:X, Float:Y, Float:Z;
    GetPlayerPos(playerid, X, Y, Z);
    if(X <= max_x && X >= min_x && Y <= max_y && Y >= min_y) return 1;
    return 0;
}
apparently "your" code name is IsPlayerInArea, and not PlayerInAreaCheck as you say, you are just contradictory yourself.
I posted two bits of code scroll up the page^^ one being "PlayerInAreaCheck" and the other being "IsPlayerInArea."

Please read my full posts before accusing me of lying and stealing other peoples code.
Reply
#16

Nah, you're the one who supposed to do this. Anyway I'm done with wasting my time here. My time is more important than talking to you.
Have fun copying.
Reply
#17

Quote:
Originally Posted by MenaceX^
Nah, you're the one who supposed to do this. Anyway I'm done with wasting my time here. My time is more important than talking to you.
Have fun copying.
You should give me your msn or xFire! I know we're going to be great friends!
Reply
#18

nothing is workin plz help
Reply
#19

*bump*
Reply
#20

You got your numbers backwards on your first post there. You wrote that X is less than or equal to a smaller number and X is larger than or equal to a larger number. So what you have there is If Player's X coordinate is OUTSIDE of these two numbers, when you wanted them to be INSIDE those two number.


Lol, if you look at it, it's like that on all of those people's posts.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)