Need help with gates..
#1

This is my current gate check:

pawn Код:
forward GateCheck1();
public GateCheck1()
{
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if (APlayerData[i][PlayerClass] == ClassSRT)
            {
                if(IsPlayerInRangeOfPoint(i, 20.0, 2294.00000000,2497.19995117,4.00000000))
                {
                    MoveObject(AutomaticGate1, 2294.00000000,2497.19995117,0.50000000, 3.0);
                }
                else
                {
                    MoveObject(AutomaticGate1, 2294.00000000,2497.19995117,4.00000000, 3.0);
                }
            }
            else
                return 0;
     }
 }
   
    return 1;
}

forward GateCheck2();
public GateCheck2()
{
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if (APlayerData[i][PlayerClass] == ClassSRT)
            {
                if(IsPlayerInRangeOfPoint(i, 20.0, 2335.00000000,2443.69995117,6.50000000))
                {
                    MoveObject(AutomaticGate2, 2335.00000000,2443.69995117,3.00000000, 3.0);
                }
                else
                {
                    MoveObject(AutomaticGate2, 2335.00000000,2443.69995117,6.50000000, 3.0);
                }
            }
            else
                return 0;
        }
    }
   
    return 1;
}
The problem is, it only opens for id 0.. Anyone knows why?

Thanks.. Kevin
Reply
#2

Because you instantly return 0 if the if statement is false, therefore as soon as the if statement is false, the loop stops and it doesn't work for any player thereafter.
Reply
#3

So, it should be, return 1;?
Reply
#4

Dont include return statement and else part. thats it
Reply
#5

Just do this
pawn Код:
else
                return 0;
into this
pawn Код:
else
Eazy does it.
Reply
#6

Not working mate, sorry.

Additional information:

The gate only opens for 1 person it deoesn't even matter if it's ID 0 or id 4..
Reply
#7

Bump.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)