public GroveGates(playerid) { if(DMZone[playerid] == 4) { for(new i = 0; i < GetMaxPlayers(); i++) { if(!IsPlayerConnected(i)) continue; if(IsPlayerInRangeOfPoint(i, 10.0, 2435.674561, -1656.416626, 13.420712) && OpenGate[i] == 0) { MoveObject(ggate, 2435.674561, -1656.416626, 13.420712, 3.0); OpenGate[i] = 1; } else if(!IsPlayerInRangeOfPoint(i, 15.0, 2435.674561, -1656.416626, 13.420712) && OpenGate[i] == 1) { MoveObject(ggate, 2435.637695, -1651.433228, 13.333119, 3.0); OpenGate[i] = 0; } } } }
for(new i = 0; i < GetMaxPlayers(); i++)
 {
  if(DMZone[i] == 4)
  {
public GroveGates(playerid)
{
 for(new i = 0; i < GetMaxPlayers(); i++)
 {
    if(DMZone[playerid] == 4)
    {
      if(IsPlayerConnected(i))
      {
        if(IsPlayerInRangeOfPoint(i, 10.0, 2435.674561, -1656.416626, 13.420712) && OpenGate[i] == 0)
        {
          MoveObject(ggate, 2435.674561, -1656.416626, 13.420712, 3.0);
          OpenGate[i] = 1;
        }
        else if(!IsPlayerInRangeOfPoint(i, 15.0, 2435.674561, -1656.416626, 13.420712) && OpenGate[i] == 1)
        {
          MoveObject(ggate, 2435.637695, -1651.433228, 13.333119, 3.0);
          OpenGate[i] = 0;
        }
      }
    }
  }
}
Originally Posted by cyber_punk
Why do you have if not is player connected continue? This should work....
|
new GroveGateOpen; //Only need 1 byte, not an entire array
public GroveGates() //You don't need a playerid parameter
{
 new PlayerNearGate;
 for(new i; i< GetMaxPlayers();i++)
 {
  if(!IsPlayerConnected(i))continue;
  if(DMZone[i]==4)
  {
   if(IsPlayerInRangeOfPoint(i, 10.0, 2435.674561, -1656.416626, 13.420712))PlayerNearGate =1;
  }
 }
 if(PlayerNearGate&&!GroveGateOpen)
 {
  MoveObject(ggate, 2435.674561, -1656.416626, 13.420712, 3.0);
  GroveGateOpen=1;
 }else{
  MoveObject(ggate, 2435.637695, -1651.433228, 13.333119, 3.0);
  GroveGateOpen=0;
 }
}