My Auto Gates won't close
#1

As the tittle says I made 3 automatic gates, Two at the LSPD, One for the garage and one for the entrance and one for the LSFD abit behind the LSPD.

Alright my problem is when I only had one gate it would close by it self but now that I have three they doesn't close anymore.

E.G I go near the first LSPD gate, it opens but doesn't close, now I go infront of the LSPD garage it opens and the first LSPD gate closes but the garage doesn't close.

Can someone help me, please.


pawn Код:
forward LspdGate();
forward LspdGarage();
forward LsfdGate();
pawn Код:
SetTimer("LsfdGate", 300, true);
SetTimer("LspdGate", 300, true);
SetTimer("LspdGarage", 300, true);
pawn Код:
public LsfdGate()
{
  for(new i = 0; i < GetMaxPlayers(); i++)
  {
    if(!IsPlayerConnected(i)) continue;
    if(IsPlayerInRangeOfPoint(i, 20.0, 1760.2771,-1696.0669,13.4326) && OpenGate[i] == 0)
    {
            MoveObject(lsfd_gate1, 1761.606445, -1691.706055, 6.469672, 1.5);
            MoveObject(lsfd_gate2, 1761.379028, -1700.606934, 6.472194, 1.5);
      OpenGate[i] = 1;
    }
    else if(!IsPlayerInRangeOfPoint(i, 20.0, 1760.2771,-1696.0669,13.4326) && OpenGate[i] == 1)
    {
      MoveObject(lsfd_gate1, 1761.606445, -1691.706055, 12.744606, 1.5);
      MoveObject(lsfd_gate2, 1761.379028, -1700.606934, 12.722128, 1.5);
      OpenGate[i] = 0;
    }
  }
}

public LspdGate()
{
  for(new i = 0; i < GetMaxPlayers(); i++)
  {
    if(!IsPlayerConnected(i)) continue;
    if(IsPlayerInRangeOfPoint(i, 15.0, 1545.6561, -1627.6211, 13.3828) && OpenGate[i] == 0)
    {
            MoveObject(lspd_gate2, 1545.754639, -1614.595459, 14.093480, 1.5);
            MoveObject(lspd_gate1, 1545.765381, -1638.832275, 14.093480, 1.5);
      OpenGate[i] = 1;
    }
    else if(!IsPlayerInRangeOfPoint(i, 15.0, 1545.6561, -1627.6211, 13.3828) && OpenGate[i] == 1)
    {
      MoveObject(lspd_gate1, 1545.765381, -1631.450073, 14.093480, 1.5);
      MoveObject(lspd_gate2, 1545.729614, -1623.504150, 14.093480, 1.5);
      OpenGate[i] = 0;
    }
  }
}

public LspdGarage()
{
  for(new i = 0; i < GetMaxPlayers(); i++)
  {
    if(!IsPlayerConnected(i)) continue;
    if(IsPlayerInRangeOfPoint(i, 10.0, 1588.489014, -1637.890991, 13.268718) && OpenGate[i] == 0)
    {
            MoveObject(lspd_garage, 1597.340332, -1637.890991, 13.268718, 1.5);
      OpenGate[i] = 1;
    }
    else if(!IsPlayerInRangeOfPoint(i, 10.0, 1588.489014, -1637.890991, 13.268718) && OpenGate[i] == 1)
    {
      MoveObject(lspd_garage, 1588.489014, -1637.890991, 13.268718, 1.5);
      OpenGate[i] = 0;
    }
  }
}
I have no errors, all the codes are at the right places


Thanks~

Reply
#2

Try this:

pawn Код:
SetTimer("LsfdGate", 5000, 0);
SetTimer("LspdGate", 5000, 0);
SetTimer("LspdGarage", 5000, 0);
Reply
#3

Quote:
Originally Posted by zєяσмαиѕтєя
Try this:

pawn Код:
SetTimer("LsfdGate", 5000, 0);
SetTimer("LspdGate", 5000, 0);
SetTimer("LspdGarage", 5000, 0);
Alright I tried what you suggested me but still doesn't work, It's wierd
I can open my first gate but it wont close, I go to the garage it closes the first gate but the garage doesn't close anymore, and for the LSFD gate it opens but doesnt close anymore
Reply
#4

PUBLICs need RETURN!!!

add them before you close last brace in every public
Код:
public LspdGarage()
{
  for(new i = 0; i < GetMaxPlayers(); i++)
  {
    if(!IsPlayerConnected(i)) continue;
    if(PlayerToPoint(8.0, i, 1588.489014, -1637.890991, 13.268718) && OpenGate[i] == 0)
    {
    		MoveObject(lspd_garage, 1597.340332, -1637.890991, 13.268718, 1.5);
      OpenGate[i] = 1;
    }
    else if(!PlayerToPoint(8.0, i, 1588.489014, -1637.890991, 13.268718) && OpenGate[i] == 1)
    {
   	  MoveObject(lspd_garage, 1588.489014, -1637.890991, 13.268718, 1.5);
      OpenGate[i] = 0;
    }
  }
  return 1;
}
Код:
public LspdGate()
{
  for(new i = 0; i < GetMaxPlayers(); i++)
  {
    if(!IsPlayerConnected(i)) continue;
    if(PlayerToPoint(10.0, i, 1545.765381, -1631.450073, 14.093480) && OpenGate[i] == 0)
    {
    		MoveObject(lspd_gate2, 1545.754639, -1614.595459, 14.093480, 1.5);
    		MoveObject(lspd_gate1, 1545.765381, -1638.832275, 14.093480, 1.5);
      OpenGate[i] = 1;
    }
    else if(!PlayerToPoint(10.0, i, 1545.765381, -1631.450073, 14.093480) && OpenGate[i] == 1)
    {
   	  MoveObject(lspd_gate1, 1545.765381, -1631.450073, 14.093480, 1.5);
   	  MoveObject(lspd_gate2, 1545.729614, -1623.504150, 14.093480, 1.5);
      OpenGate[i] = 0;
    }
  }
  return 1;
}
Код:
public LsfdGate()
{
  for(new i = 0; i < GetMaxPlayers(); i++)
  {
    if(!IsPlayerConnected(i)) continue;
    if(PlayerToPoint(10.0, i, 1761.606445, -1691.706055, 12.744606) && OpenGate[i] == 0)
    {
    		MoveObject(lsfd_gate1, 1761.606445, -1691.706055, 6.469672, 1.5);
    		MoveObject(lsfd_gate2, 1761.379028, -1700.606934, 6.472194, 1.5);
      OpenGate[i] = 1;
    }
    else if(!PlayerToPoint(10.0, i, 1761.606445, -1691.706055, 12.744606) && OpenGate[i] == 1)
    {
   	  MoveObject(lsfd_gate1, 1761.606445, -1691.706055, 12.744606, 1.5);
   	  MoveObject(lsfd_gate2, 1761.379028, -1700.606934, 12.722128, 1.5);
      OpenGate[i] = 0;
    }
  }
  return 1;
}
ALSO leave like that!

Код:
SetTimer("LsfdGate", 300, true);
SetTimer("LspdGate", 300, true);
SetTimer("LspdGarage", 300, true);
Reply
#5

Quote:
Originally Posted by Seif_
Quote:
Originally Posted by TMasters.tk
PUBLICs need RETURN!!!
No they don't, stop posting false and useless information everytime.

Use IsPlayerInRangeOfPoint instead of PlayerToPoint.
Alright I did what you said and they still doesn't close somehow
Reply
#6

*bump*
Reply
#7

pawn Код:
SetTimer("LspdGarage", 5000, true);
new LspdGarageGate = 0; //closed
pawn Код:
public LspdGarage()
{
  new max = GetMaxPlayers();
  for(new i = 0; i < max; i++)
  {
    if(!IsPlayerConnected(i)) continue;
    if(IsPlayerInRangeOfPoint(i, 8.0, 1588.489014, -1637.890991, 13.268718) && OpenGate[i] == 0)
    {
        if(LspdGarageGate == 0)
        {
                MoveObject(lspd_garage, 1597.340332, -1637.890991, 13.268718, 1.5); //open
            LspdGarageGate = 1;
        }
        else
        {
            MoveObject(lspd_garage, 1588.489014, -1637.890991, 13.268718, 1.5); //close
            LspdGarageGate = 0;
        }
    }
  }
}
Reply
#8

Thanks alot it now works

Thanks again
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)