04.12.2009, 19:38
Let's think the logic behind it:
Let's say you have, for example, 3 players connected to the server, ids 0, 1 and 2. ID 1 moves towards a gate. What does the timer do:
It goes player by player, checks their position and moves the gate. So what would it exactly do?
Checks ID 0 position -> it's away from the gate -> it gets closed.
Checks ID 1 position -> it's near the gate -> it gets opened.
Checks ID 2 position -> it's away from the gate -> it gets closed.
So, what basicly happens here, is that it closes automatly after it starts to get opened, and that happens every time the timer function is executed, so you'll be seeing it as if it was "stuck" or something. To solve this you could have a variable, and set it to 1 if there is someone near the door. Then, if the variable is not 1, you can check the position of the rest of the players. If it's 1, just skip them. Once he went away from the door, set it back at 0, so it will check for every player.
Let's say you have, for example, 3 players connected to the server, ids 0, 1 and 2. ID 1 moves towards a gate. What does the timer do:
It goes player by player, checks their position and moves the gate. So what would it exactly do?
Checks ID 0 position -> it's away from the gate -> it gets closed.
Checks ID 1 position -> it's near the gate -> it gets opened.
Checks ID 2 position -> it's away from the gate -> it gets closed.
So, what basicly happens here, is that it closes automatly after it starts to get opened, and that happens every time the timer function is executed, so you'll be seeing it as if it was "stuck" or something. To solve this you could have a variable, and set it to 1 if there is someone near the door. Then, if the variable is not 1, you can check the position of the rest of the players. If it's 1, just skip them. Once he went away from the door, set it back at 0, so it will check for every player.