MultiPlayer with GNet for Beginners (BlitzMax)

Started by Midimaster, July 14, 2023, 08:28:32

Previous topic - Next topic

Derron

Maybe add this:
Code (Blitzmax) Select
Graphics 400,300
Local modeSelected:Int = 0
Repeat
Cls
If KeyHit(KEY_C) Then modeSelected = 1
If KeyHit(KEY_S) Then modeSelected = 2
DrawText("Press C for client mode.", 20, 50)
DrawText("Press S for server mode.", 20, 75)
Flip 0
Until modeSelected

...

Global I_Am_Server:Int = 0
if modeSelected = 1 Then I_Am_Server = False
if modeSelected = 2 Then I_Am_Server = True
(or adjust similar)

This allows running the same binary and select client or server on startup


bye
Ron

William

#16
Is there a clearer way of server timeout like checking if the gnetconnect = true? checking server connection.
im still interested in game app development even if its oldschool. i have ideas i want to try myself in this project if i can ever accomplish it.

Midimaster

My skills in GNET are not very deep, So I can only tell, what is possible with the visible code part of GNet....


Server time out? Who wants to know? The server or the clients?

In your server code the server can report nothing to the others. In my way of writing the server, the server has a GObj too. Means he can report timestamps every xx msec via Slot 32.

On the clients side the clients can see how this timestamp changes all the time. If it does not change any longer, this means a time-out. If the clients cannot find the server's GObj anymore this means the servers has quit or plans to quit. They can react.



If I were you, I would not spend to much time in finding out, why the server sometimes crash.... You and me do not have the deep skills to investigate here.   Continue with your game and develope other parts meanwhile. The BlitzMax GitHub team will find a solution someday. 



 
...back from North Pole.

funkheld