I've decided to make a topic about it, because I decided to start my own server and do all the scripting for it, and apparently bugs appear sometimes...
Starting with something that just happened...
Yesterday I completed (or thought so) a script for my server,
Haywire CTF, that makes it put players as spectator if there are already an amount of people playing. On my server I set this limit to 10. I had tested it on bots first and it was working quite well, so I did some small final adjustments before going live.
BAD IDEA. I changed the server setting to add the server to the lobby; I joined; I waited... Slowly, people started joining.
At some point in time, the player count was being about 6-9, going up and down a bit, kinda like a cubed sine wave. I was ofc thinking about how the 11th player would react to the awesome script! (
"omfg wtf stupid queue qq") Then the 10th player joined, and all havok occurred:
[...]
► + .from russia with love has joined alpha team.
► + .from russia with love has joined spectators.
► + .from russia with love has joined alpha team.
► + .from russia with love has joined spectators.
► + .from russia with love has joined alpha team.
► + .from russia with love has joined spectators.
► + .from russia with love has joined alpha team.
► + .from russia with love has joined spectators.
► + .from russia with love has joined alpha team.
► + .from russia with love has joined spectators.
► + .from russia with love has joined alpha team.
► + .from russia with love has joined spectators.
► + .from russia with love has joined alpha team.
► + .from russia with love has joined spectators.
► + .from russia with love has joined alpha team.
► + .from russia with love has joined spectators.
[...]
Why? I had somehow in my haste to get the script done put ">=" instead of ">"!
![Shocked :o](https://static.forums.soldat.pl/Smileys/classic/shocked.gif)
So what was happening was that the 10th guy joined, and the script checked this:
if (AlphaPlayers + BravoPlayers >= PlayerLimit) [...]
That was true, which sent him to the join queue (spectator). Then there was another code right after it which looked like this:
while (AlphaPlayers + BravoPlayers < PlayerLimit)[...]
And that code sent him back to alpha team...
I guess someone must have had similar stuff happen, considering how little time I've spent on scripting. So yeah, let everyone know about those stupid mistakes, so people can laugh at you.
Related link