SA-MP Forums Archive
Problem with IsPlayerInArea and killing - 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: Problem with IsPlayerInArea and killing (/showthread.php?tid=134004)



Problem with IsPlayerInArea and killing - Revenation - 14.03.2010

Okay well, I have mapped my own island in the sea and everything and I would like it so that you die when you go on it if you aren't an RCON Admin, This is the code I am trying to use.

Код:
forward IPIA(playerid);

public IPIA(playerid)
{
  if(IsPlayerInArea(playerid, -3629.523925, -4407.841308, 1020.867858, -193.529113))
  {
    if(IsPlayerAdmin(playerid) == 1)
    {
	GameTextForPlayer(playerid, "~g~Welcome to the Island", 500, 1);
    }
    else
    {
    	GameTextForPlayer(playerid, "~r~You are not permitted to enter this island", 1000, 1);
      SetPlayerHealth(playerid, 0);
      
    }
  }
}

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;
}
It compiles fine and everything, no errors or warnings, but when I go ingame and go to my island, it doesnt do anything, as in I dont die or get any text and I am pretty sure the co-ords are right, I used seif's co-ords maker.


Re: Problem with IsPlayerInArea and killing - Fedee! - 14.03.2010

Try this:

pawn Код:
forward IPIA(playerid);
public IPIA(playerid)
{
  if(IsPlayerInArea(playerid, -3629.523925, -4407.841308, 1020.867858, -193.529113) && IsPlayerAdmin(playerid) == 1)
  {
    GameTextForPlayer(playerid, "~g~Welcome to the Island", 5000, 1);
    }
    else GameTextForPlayer(playerid, "~r~You are not permitted to enter this island", 5000, 1); SetPlayerHealth(playerid, 0.0);
}

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: Problem with IsPlayerInArea and killing - Revenation - 14.03.2010

Tried that, sadly still the same problem, nothing happens.. :S Im not sure but maybe a timer is needed for it to check if you are in the area? I dont really know how timers work and how I would put it in though. D:


Re: Problem with IsPlayerInArea and killing - Fedee! - 14.03.2010

Lol yes ^^

Under OnGameModeInit put:

pawn Код:
SetTimer("IPIA", 1000, true);



Re: Problem with IsPlayerInArea and killing - Revenation - 14.03.2010

Okay, that worked as in I die now, but the problem now is I die everywhere in SA XDD.. Also when im rcon logged in I still get the message and get killed. :P


Re: Problem with IsPlayerInArea and killing - Fedee! - 14.03.2010

Quote:
Originally Posted by Revenation
Okay, that worked as in I die now, but the problem now is I die everywhere in SA XDD.. Also when im rcon logged in I still get the message and get killed. :P
pawn Код:
forward IPIA(playerid);
public IPIA(playerid)
{
  if(IsPlayerInArea(playerid, -3629.523925, -4407.841308, 1020.867858, -193.529113) && IsPlayerAdmin(playerid))
  {
    GameTextForPlayer(playerid, "~g~Welcome to the Island", 5000, 1);
    }
    else GameTextForPlayer(playerid, "~r~You are not permitted to enter this island", 5000, 1); SetPlayerHealth(playerid, 0.0);
}

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;
}
Rcon fixed.. you die everywhere because your cords are wrog.. check them.


Re: Problem with IsPlayerInArea and killing - Revenation - 14.03.2010

Nvm, I fixed it, the co-ords were right it was just my original code was right and it worked with that! Thanks a lot, all done now, thanks for ya help Fedee!


Re: Problem with IsPlayerInArea and killing - Fedee! - 14.03.2010

You're welcome


Re: Problem with IsPlayerInArea and killing - Revenation - 14.03.2010

Aww man, I thought it all worked, but it does except it only works on ID 0! I got my friend to join and it doesnt do anything for ID 1, it only affects ID 0. :S, Whats up with that?


Re: Problem with IsPlayerInArea and killing - Fedee! - 14.03.2010

Quote:
Originally Posted by Revenation
Aww man, I thought it all worked, but it does except it only works on ID 0! I got my friend to join and it doesnt do anything for ID 1, it only affects ID 0. :S, Whats up with that?
Is he on RCON?