After a server is created the the player that owns the server joins the game and and the server stores this data on his side.
Later on another player joins the server that need the data that says [The server owner is in game].
It's easy to send that data when both players connected because the server can send it directly to another player.
what is the best way to do it?
Edit: Thats how I did that
func _ready():
get_tree().connect("network_peer_connected", self, "_player_connected")
get_tree().connect("network_peer_disconnected", self, "_player_disconnected")
players[1] = 1
func _player_connected(id):
if get_tree().is_network_server():
players[id] = id
else:
rpc_id(1,"sync_func")
func _player_disconnected(id):
players.erase(id)
remote func sync_func():
for peers in get_tree().get_network_connected_peers():
if peers != 1:
rpc_id(peers,"sync_players",players)
remote func sync_players(player_data):
players = player_data