[SOLVED] Lan Multiplayer block spawning problem

Etendo

Member
Hello. So I have this block game I started a few weeks back. I've gotten the gameplay working, recently I added lan multiplayer with GMnet, which I followed a tutorial to do. It all works, server, connecting, sending and receiving input. But I'm having a slight issue. I have block generators for the first player and second players that spawn one block at a time in their respective section. If you go in the game alone, they work fine. However, if you open a server, have the player join then start the game, they spawn 2 blocks in each section, which causes them to collide, get stuck and cause a game over. I believe it's because both the first player window and second player are running the codes at the same time, making it do it twice for each. I'm just looking for help to maybe point me in the right direction, as I'm not familiar with multiplayer stuff in GM at all, so any help would be very appreciated.

Here's a video of what's going on:

Here's the tutorial I followed:

Thanks in advance.
 

Simon Gust

Member
How do you suggest we find the Problem by watching a 50 minute tutorial without seeing your Code? What should we do? Trying to find the mistakes in the tutorial?
 

Etendo

Member
Well, no, it's just for reference. I'm not sure what code I'm to put, as there is a lot. And just mass dropping it in probably wouldn't help much. I'm not sure what's causing the issue, so how I don't know what to put. Sorry I for being foolish I guess.
 

rytan451

Member
Two different explanations depending on the model of your game.

Peer-to-peer:
Both players are adding a block each to the left side, thus causing two to appear. To fix this, you need to either:
A. Make the block adding deterministic so both players add the same block to the same position on their ends
B. Make the two players negotiate where the block will be placed, and collectively decide on only one position.

Client-server:
The client is overstepping its bounds, and adding a block to the game on top of the block that's already being added by the server. The server then complies to the client-side action, adding the block. To fix this, simply make sure the server is well-defined and that only it adds blocks.
 

Etendo

Member
Two different explanations depending on the model of your game.

Peer-to-peer:
Both players are adding a block each to the left side, thus causing two to appear. To fix this, you need to either:
A. Make the block adding deterministic so both players add the same block to the same position on their ends
B. Make the two players negotiate where the block will be placed, and collectively decide on only one position.

Client-server:
The client is overstepping its bounds, and adding a block to the game on top of the block that's already being added by the server. The server then complies to the client-side action, adding the block. To fix this, simply make sure the server is well-defined and that only it adds blocks.
I didn't even think about the client overstepping the server. Thank you very much! I will start looking into that.
 

Etendo

Member
So, I got the fix. After rytan451's comment, and the help from another person, I needed to make it so the server only spawns them. In which I accomplished by using the following code on any object that makes objects and some minor tweaking.

if htme_isServer()
{
block creation code goes here
}

Thanks for the help!
 
Top