29.03.2013, 12:18
In most, or even all game modes, the most common algorithm to send local messages is to loop through all
connected players, get their distance from the player that sent the message and send the message if the distance isn't too big.
Using Incognito's Streamer Plugin and Y_Less' y_iterate (AKA foreach) I came up with another way of doing it.
However I'm not sure if its more efficient for the long term.
For every player, there's a 3d sphere zone created and attached to the player.
Multi-dimensional iterator to store the players in each area.
When players enter or leave an area they get added to the iterator of that area or removed from it respectively.
And finally whenever there's a need to send a local message it will only loop through the players that are
in the area of the player that sent the message.
This way does take much more memory, and I suspect that it might be less efficient when
there are many people online (players entering and leaving areas all the time...)
The main use of those local messages are for roleplay servers that have different types of chat ranges, that means more zones and more memory.
I want to hear your opinion of the algorithm I suggested here, what do you think?
connected players, get their distance from the player that sent the message and send the message if the distance isn't too big.
Using Incognito's Streamer Plugin and Y_Less' y_iterate (AKA foreach) I came up with another way of doing it.
However I'm not sure if its more efficient for the long term.
For every player, there's a 3d sphere zone created and attached to the player.
Multi-dimensional iterator to store the players in each area.
When players enter or leave an area they get added to the iterator of that area or removed from it respectively.
And finally whenever there's a need to send a local message it will only loop through the players that are
in the area of the player that sent the message.
This way does take much more memory, and I suspect that it might be less efficient when
there are many people online (players entering and leaving areas all the time...)
The main use of those local messages are for roleplay servers that have different types of chat ranges, that means more zones and more memory.
I want to hear your opinion of the algorithm I suggested here, what do you think?