Hello guys,
i made a game where a player can host or connect to a game.
So if i click on host it shows a list of connected players and there is only me.
Now if a client clicks on connect the client gets also a list of connected players and there are me(the host) and him(the connected client)
but on the host there shows only himself(the host)
global NetworkID as integer
global AreWeConnected as integer
AreWeConnected = 0
type ClientType
id as integer
name as string
sprite as integer
pos_x as float
pos_y as float
endtype
global clients as ClientType[]
function CreateLobbyNetwork()
NetworkID = HostNetwork("Somigo Vallay Net", "Player1", 48230)
AreWeConnected = 1
endfunction
function JoinLobbyNetwork()
NetworkID = JoinNetwork("25.91.76.76", 48230, "Player2")
t# = timer()
do
c = GetNetworkNumClients(NetworkID)
if c > 1
AreWeConnected = 1
exit
endif
if timer() - t# > 4.0
Print("Es konnte keine Verbindung zum Host aufgebaut werden.")
exit
endif
sync()
loop
endfunction
function UpdateClientLobbyNetwork()
for i = 1 to 4 step 1
if i = 1
id = GetNetworkFirstClient(NetworkID)
else
id = GetNetworkNextClient(NetworkID)
endif
if id = 0 then exit
exists as integer
exists = 0
for j = 0 to clients.length step 1
if id > 1 AND clients[j].name = GetNetworkClientName(NetworkID, id)
exists = 1
Break()
endif
next j
if exists = 0
row_client as ClientType
row_client.id = id
row_client.name = GetNetworkClientName(NetworkID, id)
row_client.sprite = CreateSprite(img_player_up_1)
SetSpriteSize(row_client.sprite, 32 * 1.3, 36 * 1.3)
endif
Print("(" + Str(id) + ")NetPlayer: " + GetNetworkClientName(NetworkID, id))
if GetNetworkClientDisconnected(NetworkID, id) = 1
DeleteNetworkClient(NetworkID, id)
for j = 0 to clients.length step 1
if clients[j].name = GetNetworkClientName(NetworkID, id)
clients.remove(j)
Break()
endif
next j
endif
next i
endfunction
Can anyone help me?
* Sorry for my bad english