SA-MP Forums Archive
Border FS? - 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)
+--- Thread: Border FS? (/showthread.php?tid=310704)



Border FS? - Gooday - 13.01.2012

Hello i saw in a lot of server they have "virtual borders" so if a server is just in LS
When someone goes to the LV bridge he got messages like
"go back to LS!"
and if he dont come back in LS he die after 5 secs.

How i can make?


Re: Border FS? - thimo - 13.01.2012

Use if(!IsPlayerInRangeOfPoint and set timer and then kill if he still not back in area


Re: Border FS? - Gooday - 13.01.2012

oh, can you post a example please and u will have +rep


Re: Border FS? - Gooday - 13.01.2012

How i can know "how mutch is" the bound i need?



I need "BONE COUNTY" and "TIERRA ROBADA" from the map NO lv


Re: Border FS? - thimo - 13.01.2012

Y Less that something else... HE wants that you get killed after 5 sec Ok Add this at GMinit:
pawn Код:
SetTimer("Bounds", 1000, true);
Now add this somewhere in ur script:
pawn Код:
forward Bounds(playerid);
public Bounds(playerid)
{
      if(!IsPlayerInRangeOfPoint(playerid, 180.0, 0.0, 0.0, 0.0))
      {
              SetTimer("Kill", 5000, false);
              return 1;
      }
      return 1;
}
now lets forward the kill thingy and ofcourse make it
pawn Код:
forward Kill(playerid);
public Kill(playerid)
{
      If(IsPlayerInRangeOfPoint(playerid, 180.0, 0.0, 0.0, 0.0))
      {
            return 1; // Do nothing
      }
      else SetPlayerHealth(playerid, 0);
      return 1;
}
Thats it i guess.. UNTESTED!
Edit: change the range coords to your needs!


Re: Border FS? - Gooday - 13.01.2012

Quote:

:\Users\Luca\Desktop\basefixed.pwn(4803) : error 001: expected token: ")", but found "{"
C:\Users\Luca\Desktop\basefixed.pwn(4814) : error 001: expected token: ")", but found "{"

Errors :/


Re: Border FS? - thimo - 13.01.2012

Edited my post try again now :P


Respuesta: Re: Border FS? - OPremium - 13.01.2012

Quote:
Originally Posted by thimo
Посмотреть сообщение
Use if(!IsPlayerInRangeOfPoint(...)) and set timer and then kill if he still not back in area
Why not using IsPlayerInArea instead?

pawn Код:
stock IsPlayerInArea(playerid, Float:minx, Float:miny, Float:maxx, Float:maxy)
{
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    if((minx <= x <= maxx) && (miny <= y <= maxy)) return true;
    return false;
}
Also... You are using SetTimer instead of SetTimerEx = Your code will only work for ID 0!

pawn Код:
forward Bounds();
public Bounds()
{
      /*
      { "Bone County",                  -480.50,   596.30,  -242.90,   869.40,  2993.80,   900.00},
      { "Tierra Robada",               -2997.40,  1659.60,  -242.90,  -480.50,  2993.80,   900.00},
      { "Tierra Robada",               -1213.90,   596.30,  -242.90,  -480.50,  1659.60,   900.00},
      */

      foreach(Player, playerid) //Change to "for(new playerid; playerid < MAX_PLAYERS; playerid++)" if you don't have foreach
      {
              if(!IsPlayerInArea(playerid, -480.50, 596.30, 869.40,  2993.80) && !IsPlayerInArea(playerid, -2997.40,  1659.60, -480.50,  2993.80) && !IsPlayerInArea(playerid, -1213.90,   596.30, -480.50,  1659.60))
              {
                      SetTimerEx("Kill", 5000, false, "d", playerid);
                      return 1;
              }
      }
      return 1;
}
pawn Код:
forward Kill(playerid);
public Kill(playerid)
{
      if(!IsPlayerInArea(playerid, -480.50, 596.30, 869.40,  2993.80) && !IsPlayerInArea(playerid, -2997.40,  1659.60, -480.50,  2993.80) && !IsPlayerInArea(playerid, -1213.90,   596.30, -480.50,  1659.60))
      {
            return 1; // Do nothing
      }
      else SetPlayerHealth(playerid, 0);
      return 1;
}



Respuesta: Re: Border FS? - OPremium - 13.01.2012

Add it in "Bounds()", like this:

pawn Код:
forward Bounds();
public Bounds()
{
      /*
      { "Bone County",                  -480.50,   596.30,  -242.90,   869.40,  2993.80,   900.00},
      { "Tierra Robada",               -2997.40,  1659.60,  -242.90,  -480.50,  2993.80,   900.00},
      { "Tierra Robada",               -1213.90,   596.30,  -242.90,  -480.50,  1659.60,   900.00},
      */

      foreach(Player, playerid) //Change to "for(new playerid; playerid < MAX_PLAYERS; playerid++)" if you don't have foreach
      {
              if(!IsPlayerInArea(playerid, -480.50, 596.30, 869.40,  2993.80) && !IsPlayerInArea(playerid, -2997.40,  1659.60, -480.50,  2993.80) && !IsPlayerInArea(playerid, -1213.90,   596.30, -480.50,  1659.60))
              {
                      SendClientMessage(playerid, 0xFF0000FF /*(Red)*/, "You have 5 seconds to go back or you will DIE!"); //<----------
                      //Anything else you want to add
                      SetTimerEx("Kill", 5000, false, "d", playerid);
                      return 1;
              }
      }
      return 1;
}
PS: I made some changes to the IsPlayerInArea code in my last post, check it!


Respuesta: Re: Border FS? - OPremium - 13.01.2012

To avoid the flood of timers/messages... Add in top of your script:

pawn Код:
new bool:OutOfBounds[MAX_PLAYERS];
And change:

pawn Код:
forward Bounds();
public Bounds()
{
      /*
      { "Bone County",                  -480.50,   596.30,  -242.90,   869.40,  2993.80,   900.00},
      { "Tierra Robada",               -2997.40,  1659.60,  -242.90,  -480.50,  2993.80,   900.00},
      { "Tierra Robada",               -1213.90,   596.30,  -242.90,  -480.50,  1659.60,   900.00},
      */

      foreach(Player, playerid) //Change to "for(new playerid; playerid < MAX_PLAYERS; playerid++)" if you don't have foreach
      {
              if(OutOfBounds[playerid]) continue; //Skips the player if we already sent the message and set the timer
              if(!IsPlayerInArea(playerid, -480.50, 596.30, 869.40,  2993.80) && !IsPlayerInArea(playerid, -2997.40,  1659.60, -480.50,  2993.80) && !IsPlayerInArea(playerid, -1213.90,   596.30, -480.50,  1659.60))
              {
                      SendClientMessage(playerid, 0xFF0000FF /*(Red)*/, "You have 5 seconds to go back or you will DIE!"); //<----------
                      //Anything else you want to add
                      SetTimerEx("Kill", 5000, false, "d", playerid);
                      OutOfBounds[playerid] = true;
                      return 1;
              }
      }
      return 1;
}
pawn Код:
forward Kill(playerid);
public Kill(playerid)
{
      if(IsPlayerInArea(playerid, -480.50, 596.30, 869.40,  2993.80) || IsPlayerInArea(playerid, -2997.40,  1659.60, -480.50,  2993.80) || IsPlayerInArea(playerid, -1213.90,   596.30, -480.50,  1659.60))
      {
            OutOfBounds[playerid] = false;
            return 1; // Do nothing
      }
      else
      {
            SetPlayerHealth(playerid, 0);
            OutOfBounds[playerid] = false;
      }
      return 1;
}
I also fixed a mistake in the Kill function