I've been working on a sourcemod script for Left 4 Dead which basically gets a players versus stats (or at least attempts to depending on their profile privacy) when they join the server.
My question has to do with how scripts themselves get executed when they are called via events, and if they are run concurrently and independently of each instance..
My script basically does the following; there are no loops or anything so my script gets 'run' whenever somebody connects to the server
- OnClientAuthorized, it checks if the person who joined is a real person (not a bot)
- If they are, it uses system2 to check their versus stats and output them to the server
The script seems to work perfectly a lot of the time; it works 100% of the time when somebody joins in the middle of a game. The problem is that if 5 or 6 people connect at the same time (such as when a map loads), it messes up and mixes up stats between people, or gives the same stat for multiple people (for example, says Player 1 and Player 2 both have 200 matches won even though Player 2 might have 400 matches won)
So I'm trying to figure out why the values seem to get mixed up in this case; I would have thought each time the script is called and run in memory that it would only be working with the steamID of the player it was called with, so is it possible sourcemod isn't fully executing the script if it's called again before it's done?