SA-MP Forums Archive
Gate opens but dosent close? - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Gate opens but dosent close? (/showthread.php?tid=125455)



Gate opens but dosent close? - Torran - 03.02.2010

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;
            }
        }
    }
}



Re: Gate opens but dosent close? - Fedee! - 03.02.2010

You have to add timers.


Re: Gate opens but dosent close? - Torran - 03.02.2010

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


Re: Gate opens but dosent close? - s0nic - 03.02.2010

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)


Re: Gate opens but dosent close? - Torran - 03.02.2010

Still dosent close


Re: Gate opens but dosent close? - GTAguillaume - 03.02.2010

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);
}



Re: Gate opens but dosent close? - s0nic - 03.02.2010

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;
        }
    }
}



Re: Gate opens but dosent close? - Joe Staff - 04.02.2010

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.


Re: Gate opens but dosent close? - Torran - 04.02.2010

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


Re: Gate opens but dosent close? - Torran - 05.02.2010

Anyone? Please help,