AutoGates not working properly.
#1

Well i have this on a timer, It's supposed to open the gates only for those who are in dmzone area 4, But the gates do not move, I have no compile errors, Just the gates don't move, Heres my code:

Код:
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;
    }
  

	}
	}
}
Do you have any ideas?
Reply
#2

pawn Код:
for(new i = 0; i < GetMaxPlayers(); i++)
  {
    if(DMZone[i] == 4)
    {
Try this way
Reply
#3

Compiles, But still doesn't work.
Reply
#4

Why do you have if not is player connected continue? This should work....

pawn Код:
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;
                }
            }
        }
    }
}

Reply
#5

Quote:
Originally Posted by cyber_punk
Why do you have if not is player connected continue? This should work....
It's the same thing basically.


Your gates don't open because even though 1 player may be near it, the others are not.

pawn Код:
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;
  }
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)