error CS0115

I was following a tutorial and the code below keeps giving me CS0115 error
Code:

using Mirror;
using TMPro;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.UI;

public class NetworkRoomPlayer : NetworkBehaviour
{
    [Header("UI")]
    [SerializeField] private GameObject lobbyUI = null;
    [SerializeField] private TMP_Text[] playerNameTexts = new TMP_Text[4];
    [SerializeField] private TMP_Text[] playerReadyTexts = new TMP_Text[4];
    [SerializeField] private Button startGameButton = null;

    [SyncVar(hook = nameof(HandleDisplayNameChanged))]
    public string DisplayName = "Loading...";
    [SyncVar(hook = nameof(HandleReadyStatusChanged))]
    public bool Isready = false;
   
    private bool isLeader;
    public bool IsLeader
    {
        set
        {
            isLeader = value;
            startGameButton.gameObject.SetActive(value);
        }
    }

    private NetworkManagerr room;
    private NetworkManagerr Room
    {

        get
        {
            if (room != null) { return room; }
            return room = NetworkManager.singleton as NetworkManagerr;
        }
    }

    public override void OnStartAuthority()
    {
        CmdSetDisplayName(PlayerNameInput.DisplayName);
        lobbyUI.SetActive(true);
    }

    public override void OnStartClient()
    {
        Room.RoomPlayer.Add(this);
        UpdateDisplay();
    }

    public override void OnNetworkDestroy()
    {
        Room.RoomPlayers.Remove(this);
        UpdateDisplay();
    }

    public void HandleReadyStatusChanged(bool oldValue, bool newValue) => UpdateDisplay();
    public void HandleDisplayNameChanged(string oldValue, string newValue) => UpdateDisplay();

    private void UpdateDisplay()
    {
        if (!hasAuthority)
        {
            foreach (var player in Room.RoomPlayers)
            {
                if (player.hasAuthority)
                {
                    player.UpdateDisplay();
                    break;
                }
            }
            return;
        }

        for (int i = 0; i < playerNameTexts.Length; i++)
        {
            playerNameTexts[i].text = "Waiting For Player... ";
            playerReadyTexts[i].text = string.Empty;
        }

        for (int i = 0; i < Room.RoomPlayers.Count; i++)
        {
            playerNameTexts[i].text = Room.RoomPlayers[i].DisplayName;
            playerReadyTexts[i].text = Room.RoomPlayers[i].ISReady ?
                "<color=green>Ready</color>" :
                "<color=red>Not Ready</color>";
        }
    }

    public void HandleReadyToStart(bool readyToStart)
    {
        if (!isLeader) { return; }
        startGameButton.interactable = readyToStart;
    }

    [Command]
    private void CmdSetDisplayName(string displayname)
    {
        DisplayName = displayname;
    }

    [Command]
    public void CmdReadyUp()
    {
        Isready = !Isready;
        Room.NotifyPlayersOfReadyState();
    }

    [Command]
    public void CmdStartGAme()
    {
        if(Room.RoomPlayers[0].connectionToClient != connectionToClient) { return; }

        //start
    }
}

Error:

I don’t know what I did wrong.

Is there a method called OnNetworkDestroy() in your base class? This code assumes there is but perhaps this code is for a different version of the networking library than the version you have now. Definitely go back to the docs for whatever networking stuff this is (Mirror?) and see about that method. It has to exist before you can override it. If it does not exist, you cannot override it, and even if you could, the library certainly isn’t calling a method that doesn’t exist.

1 Like

I just went to the docs, it does exist but I still get this error.