Hi,
I'm starting an unpretentious tycoon-like game: I start with the beginning of the game, the registration of the players (based on multipleyrs bomber: with autolad and lobby) all this is going well the client and server are ok. Then the players have to choose a cargo ship and a port of departure (it's a sea tycoon) and there is no way to tell the other players that this cargo ship and this port are required, so they are no longer available.
But there is no information circulating between the cli and the serv. I confess that I'm new to godot, and I have trouble with the network logic used by godot.
extract code gamestat.gb (autoload) :
var cargos = {0:["res://images/cargo_bleu.png", "Bleu", false], 1:["res://images/cargo_bordeau.png", "Bordeau", false], 2:["res://images/cargo_jaune.png", "Jaune", false], 3:["res://images/cargo_rouge.png", "Rouge", false], 4:["res://images/cargo_vert.png", "Vert", false], 5:["res://images/cargo_violet.png", "Violet", false]}
remotesync func set_cargos(idx):
cargos[idx][2] = true
emit_signal("cargos_changed", idx) # => lobby.supprime_cargo(index)
lobby.gb
func _on_ItemList_item_selected(index):
# cargo
index_cargo = index
func _on_id_pressed(idx):
# port
index_port = idx
func _on_OkCargo_pressed():
if index_cargo == 999 or index_port == 999:
get_node(ctrl_error_cargo).text = "Vous devez sélectionner un cargo et un port"
get_node(ctrl_timer_cargo).start(4)
else:
# jusqu'ici tout va bien index_cargo et index_port sont ok
if is_network_master():
gamestate.set_cargos(index_cargo)
else:
rpc_id(1, "gamestate.set_cargos", index_cargo)
func supprime_cargo(idx):
get_node(ctrl_cargo + "/ChoixCargo/ItemList").set_item_disabled(idx, true)
A debugger error is displayed: when the client chooses its cargo, the debugger on the server sends:
E 0:00:34:0885 RPC 'gamestate.setcargos' is not allowed on node
/root/lobby from: 496164672. Mode is 0, master is 1.
core/io/multiplayerapi.cpp:288 @ processrpc()
No error is reported on the client in any case.
Locally on the server, the cargo dictionary is up to date when the server chooses its cargo but the client doesn't receive anything, i.e. cargo is not up to date in the client and prints placed in remotesync func setcargos(idx), func supprimecargo(idx) are not displayed with the client code.
When the client chooses his cargo the only printout that appears is the one placed in func delete_cargo(idx) after rpcid(1, "gamestate.setcargos", cargo_index) Dictionnary cargos no update in the code executed by the client.
No items are disabled except for the server's item for its own choice and at home only.