Whats wrong with this?
#1

pawn Код:
public InAreaChecker()
{
  for(new i; i<MAX_PLAYERS; i++)
  {
    if(IsPlayerInArea(i, 443.7593, 373.692, 2475.709, 2405.642))
    {
      SetPlayerHealth(i, 9999999);
      SetPlayerChatBubble(i, "is in safe zone", 0xFFFF00AA, 100.0, 10000);
      GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~n~~n~~w~You are Currently in ~g~SAFE Zone~w~.",10000,5);
    }
    else
    {
      SetPlayerHealth(i, 100);
      GameTextForPlayer(i, " ",3000,5);
      SetPlayerChatBubble(i, " ", 0xFF0000FF, 100.0, 10000);
    }
  }
  return 1;
}
It works and all, but when I'm out of the area and I lose health, it resets to 100 again.
Reply
#2

Make a variable to check if the player has been given the health or not .

pawn Код:
new CheckVariable[MAX_PLAYERS];

public InAreaChecker()
{
  for(new i; i<MAX_PLAYERS; i++)
  {
    if(IsPlayerInArea(i, 443.7593, 373.692, 2475.709, 2405.642) && CheckVariable[playerid] == 0)
    {
      SetPlayerHealth(i, 9999999);
      SetPlayerChatBubble(i, "is in safe zone", 0xFFFF00AA, 100.0, 10000);
      GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~n~~n~~w~You are Currently in ~g~SAFE Zone~w~.",10000,5);
      CheckVariable[playerid] = 1;
    }
    else if(CheckVariable[playerid] == 1 && !IsPlayerInArea(i, 443.7593, 373.692, 2475.709, 2405.642))
    {
      SetPlayerHealth(i, 100);
      GameTextForPlayer(i, " ",3000,5);
      SetPlayerChatBubble(i, " ", 0xFF0000FF, 100.0, 10000);
      CheckVariable[playerid] = 0;
    }
  }
  return 1;
}
Try that.
Reply
#3

Quote:
Originally Posted by [HiC
TheKiller ]
Make a variable to check if the player has been given the health or not .

pawn Код:
new CheckVariable[MAX_PLAYERS];

public InAreaChecker()
{
  for(new i; i<MAX_PLAYERS; i++)
  {
    if(IsPlayerInArea(i, 443.7593, 373.692, 2475.709, 2405.642) && CheckVariable[playerid] == 0)
    {
      SetPlayerHealth(i, 9999999);
      SetPlayerChatBubble(i, "is in safe zone", 0xFFFF00AA, 100.0, 10000);
      GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~n~~n~~w~You are Currently in ~g~SAFE Zone~w~.",10000,5);
      CheckVariable[playerid] = 1;
    }
    else if(CheckVariable[playerid] == 1 && !IsPlayerInArea(i, 443.7593, 373.692, 2475.709, 2405.642))
    {
      SetPlayerHealth(i, 100);
      GameTextForPlayer(i, " ",3000,5);
      SetPlayerChatBubble(i, " ", 0xFF0000FF, 100.0, 10000);
      CheckVariable[playerid] = 0;
    }
  }
  return 1;
}
Try that.
Damn it, I always forget to make a variable. Thanks a lot
Reply
#4

I got the playerid error but I fixed it using "i"
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)