Leave online game

Godot Version

Question

Hi, I have a problem on my multi game, I made a buton that allows to quit the game:

func _on_quit_pressed():
    quit.rpc_id(1)
    get_tree().change_scene_to_file("res://Online/world.tscn")


@rpc("call_local")
func quit():
    var player_id = get_node(str(multiplayer.get_remote_sender_id()))
    player_id.queue_free()

But the host always sees the player who has changed the scene, and receives errors over and over again:

E 0:00:13:0334   on_sync_receive: Ignoring sync data from non-authority or for missing node.
  <Erreur C++>   Condition "true" is true. Continuing.
  <Source C++>   modules/multiplayer/scene_replication_interface.cpp:879 @ on_sync_receive()

E 0:00:13:0351   get_node: Node not found: "/root/World/1" (absolute path attempted from "/root").
  <Erreur C++>   Method/function failed. Returning: nullptr
  <Source C++>   scene/main/node.cpp:1635 @ get_node()

E 0:00:13:0351   get_cached_object: Failed to get cached path: /root/World/1.
  <Source C++>   modules/multiplayer/scene_cache_interface.cpp:256 @ get_cached_object()

E 0:00:13:0351   process_rpc: Invalid packet received. Requested node was not found.
  <Erreur C++>   Parameter "node" is null.
  <Source C++>   modules/multiplayer/scene_rpc_interface.cpp:212 @ process_rpc()

then it repeats itself.

I found the solution to my problem, there was no need to take the id of the player and stop it since the problem did not come from there, but from the port that remains connected to the player if I understood correctly. So the correct code is:

func _on_quit_pressed():
    multiplayer.multiplayer_peer = null
	change_scene_to_file("res://Online/world.tscn")
1 Like