I am trying to make LAN multiplayer game but it doesn't work the way it should work. It doesn't update sprite position. Here is my code:
if multiplayerStart = 1 and IsNetworkActive ( NetworkID ) <> 0
id = GetNetworkFirstClient ( NetworkID )
while id <> 0
Print ( GetNetworkClientName ( NetworkID, id ) )
id = GetNetworkNextClient ( NetworkID )
endwhile
if player1Start = 1
SetSpritePositionByOffset ( player1.spr, playerX#, playerY# )
msg = CreateNetworkMessage()
AddNetworkMessageFloat( msg, playerX# )
AddNetworkMessageFloat( msg, playerY# )
SendNetworkMessage( NetworkID, 0, msg )
endif
if player2Start = 1
msg = GetNetworkMessage( NetworkID )
SetSpriteVisible( player1.spr, 1 )
while msg <> 0
playerX# = GetNetworkMessageFloat( msg )
playerY# = GetNetworkMessageFloat( msg )
SetSpritePositionByOffset ( player1.spr, playerX#, playerY# )
DeleteNetworkMessage ( msg )
msg = GetNetworkMessage ( NetworkID )
endwhile
endif
endif
This is my first multiplayer game and I don't know what is wrong with this code. I hope that someone can help me with this. Thanks.