Luke Pierson
Member
Hey GMC! Big question:
So, I'm making an online 2 player game. So lots of people connected to the server, but when people want to play, they get paired with only one other player. To integrate matchmaking between two players, I send the server the username of every player that presses the play button. In the server, I set a variable when reading the buffer that contains the searching player's username. I call this variable playerSearchingUsername.
I want to insert that player's username via the variable into a ds_list I've created called playerSearching (and yes I made sure to destroy it at the end of the game). So I was doing ds_list_add(playerSearching, playerSearchingUsername);
So now that the player has been added I want to check if the list has 2 or more players in it:
if ds_list_size(playerSearching) >= 2 {
//do stuff
}
if there's not more than 2 people wanting to play, then I send a response 0 to the searching client, informing them that they have been unsuccessful in joining a game and then deletes their name from the list
If the condition is true, I now want to read/extract the data from the list and grab the first two players (the one's who have been waiting in the list the longest) and pair them together as player 1 and 2, sending them into the game room. And of course, the server will have to differentiate between multiple games as to who player 1 and 2 are. How do I do this? I know this is a tall order, but it would mean the world to me if I could get some help!
And if my logic on how to do anything in the above is faulty, please let me know! Thanks in advance!
So, I'm making an online 2 player game. So lots of people connected to the server, but when people want to play, they get paired with only one other player. To integrate matchmaking between two players, I send the server the username of every player that presses the play button. In the server, I set a variable when reading the buffer that contains the searching player's username. I call this variable playerSearchingUsername.
I want to insert that player's username via the variable into a ds_list I've created called playerSearching (and yes I made sure to destroy it at the end of the game). So I was doing ds_list_add(playerSearching, playerSearchingUsername);
So now that the player has been added I want to check if the list has 2 or more players in it:
if ds_list_size(playerSearching) >= 2 {
//do stuff
}
if there's not more than 2 people wanting to play, then I send a response 0 to the searching client, informing them that they have been unsuccessful in joining a game and then deletes their name from the list
If the condition is true, I now want to read/extract the data from the list and grab the first two players (the one's who have been waiting in the list the longest) and pair them together as player 1 and 2, sending them into the game room. And of course, the server will have to differentiate between multiple games as to who player 1 and 2 are. How do I do this? I know this is a tall order, but it would mean the world to me if I could get some help!
And if my logic on how to do anything in the above is faulty, please let me know! Thanks in advance!