Gate opens but dosent close?
#1

I walk up to my gate, It opens, If i walk away, It stays open?
It should close? But why, I checked my coordinates..

pawn Код:
public CheckGate(playerid)
{
  for(new i;i<MAX_PLAYERS;i++)
  {
    if(!IsPlayerConnected(i)) continue;
    if(IsPlayerInRangeOfPoint(i, 10.0, 1589.048096, -1637.884277, 12.902792) && c_gate_status == 0)
    {
    if(GetPlayerTeam(playerid) == 1)
    {
            MoveObject(c_gate, 1596.955811, -1637.884277, 12.902792, 2);
            PlayerPlaySound(i, 1165, 1589.048096, -1637.884277, 12.902792);
            c_gate_status = 1;
    }
    else if(!IsPlayerInRangeOfPoint(i, 10.0, 1589.048096, -1637.884277, 12.902792) && c_gate_status == 1)
    {
            MoveObject(c_gate, 1589.048096, -1637.884277, 12.902792, 2);
            PlayerPlaySound(i, 1165, 1589.048096, -1637.884277, 12.902792);
            c_gate_status = 0;
            }
        }
    }
}
Reply
#2

You have to add timers.
Reply
#3

I have...
The gate wouldnt open if i didnt add timers
Reply
#4

Try this:
pawn Код:
public CheckGate(playerid)
{
    for(new i;i<MAX_PLAYERS;i++)
    {
        if(!IsPlayerConnected(i)) continue;
        if(IsPlayerInRangeOfPoint(i, 10.0, 1589.048096, -1637.884277, 12.902792) && c_gate_status == 0)
        {
            if(GetPlayerTeam(playerid) == 1)
            {
                MoveObject(c_gate, 1596.955811, -1637.884277, 12.902792, 2);
                PlayerPlaySound(i, 1165, 1589.048096, -1637.884277, 12.902792);
                c_gate_status = 1;
            }
        }
        else
        {
            MoveObject(c_gate, 1589.048096, -1637.884277, 12.902792, 2);
            PlayerPlaySound(i, 1165, 1589.048096, -1637.884277, 12.902792);
            c_gate_status = 0;
        }
    }
}
Tho wouldn't it just be CheckGate() and GetPlayerTeam(i)
Reply
#5

Still dosent close
Reply
#6

Mabye this?
pawn Код:
public CheckGate()
{
    for(new i;i<MAX_PLAYERS;i++)
    {
        if(!IsPlayerConnected(i)) continue;
        if(IsPlayerInRangeOfPoint(i, 10.0, 1589.048096, -1637.884277, 12.902792))
        {
            if(GetPlayerTeam(i) == 1)
            {
                MoveObject(c_gate, 1596.955811, -1637.884277, 12.902792, 2);
                PlayerPlaySound(i, 1165, 1589.048096, -1637.884277, 12.902792);
                return;
            }
        }
    }
    MoveObject(c_gate, 1589.048096, -1637.884277, 12.902792, 2);
    PlayerPlaySound(i, 1165, 1589.048096, -1637.884277, 12.902792);
}
Reply
#7

Check this out..
pawn Код:
//modify you timer to SetTimer("CheckGate",..
forward CheckGate();
public CheckGate()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(!IsPlayerConnected(i)) continue;
        if(IsPlayerInRangeOfPoint(i, 10.0, 1589.048096, -1637.884277, 12.902792))
        {
            if(c_gate_status == 0)
            {
                if(GetPlayerTeam(i) == 1)
                {
                    MoveObject(c_gate, 1596.955811, -1637.884277, 12.902792, 2);
                    PlayerPlaySound(i, 1165, 1589.048096, -1637.884277, 12.902792);
                    c_gate_status = 1;
                }
            }
        }
        else if(c_gate_status == 1)
        {
            MoveObject(c_gate, 1589.048096, -1637.884277, 12.902792, 2);
            PlayerPlaySound(i, 1165, 1589.048096, -1637.884277, 12.902792);
            c_gate_status = 0;
        }
    }
}
Reply
#8

The method you're using will only work if everyone in the server (or the last person on the server) is next to the gate.

Automatic Gates Tutorial <-- this is accurate and works.
Reply
#9

If i add
pawn Код:
GetPlayerTeam[playerid] = 1;
I get errors about Undefined symbol: Playerid
Reply
#10

Anyone? Please help,
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)