01.11.2009, 08:23
Quote:
Originally Posted by Joe Staff
There's a problem with your code though. If one player is close to it, the gate opens, but since other players are away from the gate, it will close. This means the gate will only open if every player is within range of the gate.
This method will fix that. pawn Код:
|
pawn Код:
new OpenGate[MAX_PLAYERS];
public CheckGate()
{
for(new i = 0; i < GetMaxPlayers(); i++)
{
if(!IsPlayerConnected(i)) continue;
if(PlayerToPoint(10.0, i, closed_X, closed_Y, closed_Z) && OpenGate[i] == 0)
{
MoveObject(c_gate, open_X, open_Y, open_Z);
OpenGate[i] = 1;
}
else if(!PlayerToPoint(10.0, i, closed_X, closed_Y, closed_Z) && OpenGate[i] == 1)
{
MoveObject(c_gate, closed_X, closed_Y, closed_Z);
OpenGate[i] = 0;
}
}
}
Oh and i had this script in 0.2X, which causes problems in 0.3a (players didnt see object movings but i am):
pawn Код:
forward CheckGate();
public CheckGate()
{
for(new i = 0; i < GetMaxPlayers(); i++)
{
if(!IsPlayerConnected(i)) continue;
if(PlayerToPoint(10.0, i, 213.8831,1875.3693,13.1470))
{
MoveObject(a51_desna,207.838668,1875.358276,13.885452,1.0);
MoveObject(a51_leva,219.970260,1875.358276,13.885452,1.0);
return 1;
}
}
MoveObject(a51_desna,211.854766,1875.358276,13.885452,1.0);
MoveObject(a51_leva,215.952407,1875.358276,13.885452,1.0);
return 1;
}
PS: Dont look at "PlayerToPoint". In my script i replaced it with "IsPlayerInRangeOfPoint" already.