diff --git a/scripts/client.gd b/scripts/client.gd index 5c0d16e..a4a5542 100644 --- a/scripts/client.gd +++ b/scripts/client.gd @@ -60,7 +60,8 @@ func _on_player_disconnected(id): if current_character.captured_by != null: current_character.captured_by.lost_one() await get_tree().create_timer(0.5).timeout - current_character.free() + if is_instance_valid(current_character): + current_character.free() x += 1 Game.player_list.erase(id) diff --git a/scripts/game.gd b/scripts/game.gd index a380ab7..273fac0 100644 --- a/scripts/game.gd +++ b/scripts/game.gd @@ -108,10 +108,12 @@ func start_game(): var map = get_tree().root.get_node("./"+map_name+"/") for i in range(player_list.size()): var obj = objective.instantiate() + obj.name = "objective" + str(i) obj.position = get_tree().root.get_node("./"+map_name+"/objective_spawns/"+str(i)).position map.add_child(obj) for i in range(player_list.size()): var obj = prison.instantiate() + obj.name = "prison" + str(i) obj.position = get_tree().root.get_node("./"+map_name+"/prison_spawns/"+str(i)).position map.add_child(obj) var i = 0 @@ -142,12 +144,14 @@ func sync_player(node_path, position, rotation, rotation2): get_tree().root.get_node(node_path).find_child("collision").rotation = rotation2 func sync_hammer(node_path, rotation): - var current_character = get_tree().root.get_node(node_path) - current_character.rotation = rotation + if get_tree().root.has_node(node_path): + var current_character = get_tree().root.get_node(node_path) + current_character.rotation = rotation func sync_computers(node_path, current): - var current_character = get_tree().root.get_node(node_path) - current_character.current = current + if get_tree().root.has_node(node_path): + var current_character = get_tree().root.get_node(node_path) + current_character.current = current func sync_beast(player): while !get_tree().root.has_node("./"+map_name+"/player"+str(player)):