Problem with IsPlayerInArea and killing
#1

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.
Reply
#2

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;
}
Reply
#3

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:
Reply
#4

Lol yes ^^

Under OnGameModeInit put:

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

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
Reply
#6

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

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!
Reply
#8

You're welcome
Reply
#9

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?
Reply
#10

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?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)