How to get around a peer doing rpc_id on itself

Godot Version

Godot 4.6.1

Question

Hi, fairly new to Godot game dev in general, so please bear with me.

I’m making a board game (kinda like monopoly), where one player also acts as the host and the others connect to him. I’m using ENetMultiplayer.

The networking architecture is server-client based, so basically everything needs to go through the server/host.

Here’s some context. I’m making a trading system between players. Player 1 contacts the server, which then contacts player 2 and the trade can start. To do this I use rpc_id to contact the server.

The problem occurs when the server/host is one of the players that is part of the trade. The rpc_id call fails, because the server is trying to rpc_id itself.

To finally get to my question, how do i get around this? I saw some people just do an if condition where they determine if the player is the server (multiplayer.is_server()) and just call the function normally and only do an rpc_id if it’s a client, but I feel like that would just lead to way too many if conditions everywhere in my code.

Check that is the player server or not in a helper function.It reduces the if-else statement spaghetti a lot.