[quote:13vtgef4]All I need is a global variable "group" for each player that is set on connection by smart random (start 1, end 3, threshold 0). Doing this would guarantee the balance between groups right ?
Well, actually it would have to be a bit different.
Since there is a player limit for each room, you need to take into consideration whether the room is already full or not.
The variable "group" won't be set on connection by the peer but by the host.
The host will have three dictionaries, one for each room, in which he stores who is in that room.
When a peer connects, the host will check the first dictionary whether it is full. If there is space, he will add the player to the dictionary and send him his group number.
If the group is full, check the next dictionary.
You can add randomness by multiple ways.
One would be to have every player set a preferred group on start which is generated randomly (pun not intended). This value is sent to the host when connected. The host will then first look in the dictionary with the number that has been sent and continue looking numerically. (System condition "For each ordered").
___________________________________
[quote:13vtgef4]Sometimes, I would need more than 3 groups
You will have to add the appropriate amount of dictionaries and change the random generation like you said.
(Checking of the dictionaries won't be affected since "For each" automatically looks at the count of the objects)
You will also have to add events to the host "On [groupX] message" to cover all groups.
______________________________________
[quote:13vtgef4]Also, when you say it will be hard for the host CPU, do you think that would actually take a lot of time to deal with all the comparisons ? More than 30 seconds ? Several minutes ?
I don't have much experience with this, but I'd say not that much. Several minutes? Definitely not.
It depends on many factors.
Of course, it depends on the computer's specs, a bit on the internet speed (not that much though) and on the amount of messages that are posted by the players at the same time.
You would really have to test this out.
One thing to experiment with would be to create a new project, designed for the host only.
This would be started first, would be no player, and his only task would be to handle everything host-related.
Having a separate host instance would increase the performance for everyone, since there won't be one player who is always doing the host tasks and the host won't have to deal with the peer-only stuff.
________________________
[quote:13vtgef4]When you are the host, you also send message with a tag corresponding to your group value and you broadcast every message you get. However, you only display those who have a tag corresponding to your group value.
Assuming, you don't go with the separate host, that is correct.
As a host, when receiving a message, you would have to get the group number of the user the message came from.
(Compare "FromID" with ID in group dictionary)
Then, you would broadcast the message to everyone with a group tag attached to it.
As a peer, when receiving such a message from the host, you would have to parse the message to retrieve the group number. Shouldn't be too difficult. (If you need help, PM me or google for it)
_________________________________________
[quote:13vtgef4]When you are a peer, you send message with a tag corresponding to your group value. And even if you get messages from everyone, you display only those that has a tag corresponding to your group value.
[quote:13vtgef4]When you are the host, you also send message with a tag corresponding to your group value and you broadcast every message you get. However, you only display those who have a tag corresponding to your group value.
Almost correct! (Again, assuming, you don't have a separate host)
As a host, you wouldn't need to send the message with a tag corresponding to your group value, thus, a regular message like a peer would send.
You can simply broadcast it, since the peers will only display messages that come from the host and are declared as "host broadcasts messsage". (Like in your .capx, you probably just wrote that wrong)
________________________________________
Something not related to the Multiplayer part:
I noticed you still have the many, many Sprite1, Sprite2, Sprite3,... events.
Did you try what I wrote on my first post? This would make it more compact and easier to handle.
Try this:
- Add a family containing all the sprites, e.g."Sprites"
- Add a family instance variable, e.g. "index"
- Edit that variable for every Sprite and set it to the Sprite's number (don't set it in the event sheet, set it in the object properties)
- Delete that long chain of conditions you referred to (Spawn=X, Spawn=Y,...) and replace it by this: