SA-MP Forums Archive
is player in area - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: is player in area (/showthread.php?tid=92458)

Pages: 1 2


is player in area - sggassasin - 20.08.2009

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


Re: is player in area - Gappy - 20.08.2009

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;
}



Re: is player in area - sggassasin - 20.08.2009

got one error


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


Re: is player in area - Gappy - 20.08.2009

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


Re: is player in area - MenaceX^ - 20.08.2009

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.


Re: is player in area - Gappy - 20.08.2009

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.



Re: is player in area - dice7 - 20.08.2009

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;
}



Re: is player in area - Gappy - 20.08.2009

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?


Re: is player in area - dice7 - 20.08.2009

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


Re: is player in area - MenaceX^ - 20.08.2009

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;
}



Re: is player in area - Gappy - 20.08.2009

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.


Re: is player in area - MenaceX^ - 20.08.2009

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..


Re: is player in area - Gappy - 20.08.2009

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.


Re: is player in area - MenaceX^ - 20.08.2009

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.


Re: is player in area - Gappy - 20.08.2009

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.


Re: is player in area - MenaceX^ - 20.08.2009

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.


Re: is player in area - Gappy - 20.08.2009

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!


Re: is player in area - sggassasin - 20.08.2009

nothing is workin plz help


Re: is player in area - sggassasin - 21.08.2009

*bump*


Re: is player in area - Joe Staff - 21.08.2009

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.