Need help with gates.. - 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)
+--- Thread: Need help with gates.. (
/showthread.php?tid=308369)
Need help with gates.. -
SomebodyAndMe - 03.01.2012
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
Re: Need help with gates.. -
JaTochNietDan - 03.01.2012
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.
Re: Need help with gates.. -
SomebodyAndMe - 03.01.2012
So, it should be, return 1;?
Re: Need help with gates.. -
Minion - 03.01.2012
Dont include return statement and else part. thats it
Re: Need help with gates.. -
CmZxC - 03.01.2012
Just do this
into this
Eazy does it.
Re: Need help with gates.. -
SomebodyAndMe - 04.01.2012
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..
Re: Need help with gates.. -
SomebodyAndMe - 05.01.2012
Bump.