RPC not calling function on server

Godot Version

v4.4.1.stable.steam [49a5bc7b6]

Question

Why is this RPC the only one that isn’t calling the server function?

Bear with me as I’m fairly new to network coding. I have a fairly simple server/client setup with multiple RPCs. All of them work except for this one and I feel its a simple setting or something I don’t quite understand about RPCs.

Client:

rpc_id(1, "set_player_ready", player_info.ready)

Server:

@rpc("call_remote", "reliable")
func set_player_ready(ready_status):
	var id = multiplayer.get_remote_sender_id()
	print("RPC received from ID ", id, " ready_status: ", ready_status)
	if id in connected_players:
		connected_players[id]["ready"] = ready_status
		print("Player ", connected_players[id].name, " is ", "ready" if ready_status else "not ready")
		update_player_list()
		broadcast_lobby_update()
	
	# Check if all players are ready
	if connected_players.size() >= 1 and _all_players_ready():
		_start_game()

I should also mention I have an error from the debugger for the RPC checksum. The odd part is I thought this was mostly due to not having the same RPCs on both the server and client but I checked and ensured that each file had the correct functions.

E 0:00:05:748 process_simplify_path: The rpc node checksum failed. Make sure to have the same methods on both nodes. Node path: Main
<C++ Source> modules/multiplayer/scene_cache_interface.cpp:121 @ process_simplify_path()

E 0:00:05:762 process_confirm_path: The rpc node checksum failed. Make sure to have the same methods on both nodes. Node path: /root/Main
<C++ Source> modules/multiplayer/scene_cache_interface.cpp:159 @ process_confirm_path()

What I don’t really understand, or know if it really matters, is why the path on one side is /root/Main and the other is just Main.

If anyone has some wisdom they could pass down it would be greatly appreciated.

Maybe it would be better to use Godot 4.x rpc calls using the callable, at least potentially better error messages.

set_player_ready.rpc_id(1, player_info.ready)
1 Like

Unfortunately it didn’t seem to give me any additional information around why its not calling the function.

Any suspicions about the debug errors? Or are they more of a warning?

check this warning in the godot docs:
https://docs.godotengine.org/en/stable/tutorials/networking/high_level_multiplayer.html#remote-procedure-calls

If a function is annotated with @rpc on the client script (resp. server script), then this function must also be declared on the server script (resp. client script). Both RPCs must have the same signature which is evaluated with a checksum of all RPCs. All RPCs in a script are checked at once, and all RPCs must be declared on both the client scripts and the server scripts, even functions that are currently not in use.

The signature of the RPC includes the @rpc() declaration, the function, return type, and the NodePath. If an RPC resides in a script attached to /root/Main/Node1, then it must reside in precisely the same path and node on both the client script and the server script. Function arguments are not checked for matching between the server and client code (example: func sendstuff(): and func sendstuff(arg1, arg2): will pass signature matching).

If these conditions are not met (if all RPCs do not pass signature matching), the script may print an error or cause unwanted behavior. The error message may be unrelated to the RPC function you are currently building and testing.

What I don’t really understand, or know if it really matters, is why the path on one side is /root/Main and the other is just Main.

the /root window viewport is created by godot:

https://docs.godotengine.org/en/stable/tutorials/scripting/scene_tree.html#root-viewport

Ah okay, its good to know that may be causing issues. I guess my question is how are they different? I create the scenes in the same way. If I go to the ‘remote’ tab when they are running the top parent node from the scene is under root.

After digging a bit I found some more info that I think I understand.
So since the function is being called from the server I set the sync to ‘call_remote’
I then no longer need the prototype function in the client.

Godot then gives me this error when I try to run it:

E 0:00:03:214   multiplayer.gd:62 @ _on_ready_button_pressed(): Unable to get the RPC configuration for the function "set_player_ready" at path: "/root/Main". This happens when the method is missing or not marked for RPCs in the local script.
  <C++ Error>   Condition "rpc_id == 65535" is true. Returning: ERR_INVALID_PARAMETER
  <C++ Source>  modules/multiplayer/scene_rpc_interface.cpp:474 @ rpcp()
  <Stack Trace> multiplayer.gd:62 @ _on_ready_button_pressed()

Am I correct to assume that by ‘local script’ its referring to the server script where the function is located?

EDIT: It seems like you still need the signature function regardless of the sync mode.
I also used get_path() on both client and server and the printed result was : /root/Main for both.