I use PER CLIENT PER OPERATION mode for this, although for the moment I'm only using 1 operation there is possibility for expansion.
DO NOT USE OPERATION 0. Start with Operation 1. Operation 0 seems to lump everyone's data into one packet space instead of keeping them separated. I discovered this when there were 5 players on the server and only one of them was moving. When I changed to operation 1 everything worked fine.
Here is an example of how I'm doing it. Let's take your 500 clients to check.
- Set up a variable to count your loops up to 25, then reset to 0.
- Every 5th loop count the first 100.
- Every 10th loop count 101 to 200.
- 15th loop, 201 to 300.
- etc..
if Loops = 5
xstart = 1 : xend = 100
endif
if Loops = 10
xstart = 101 : xend = 200
endif
` etc..
for x = xstart to xend
Packet = mn Recv UDP(0, Packet, x, 1)
if Packet > 0
` process your packet
endif
next x
This is a very simplified example, but it does at least 2 things.
1. It checks all your players in a very short amount of time.
2. It saves CPU cycles, thus not killing your framerate.
You can apply this same concept to several other things that don't necessarily need to happen EVERY game loop, and your game's performance will improve dramatically.