Saving OnClientDisconnect

Hi guys!

Hoping you can help me with a little something. I have created a save/load script, and it works great for saving/loading by pressing buttons. Now I want to make it automatic, and I can’t really figure it out.I wanted to run the Save() function when a player disconnects, so I tried this:

public override void OnClientDisconnect(NetworkConnection conn)
{
base.OnClientDisconnect(conn);
print("Client disconnects");
Save();
}

However, this needs to derive from : NetworkManager, and I already have another script that derives from NetworkManager, and you can only have one script that does that.

So I tried having this other script that derives from NetworkMangager access the Save() function from the first script, but I can’t make that work either.

Can anyone tell me how to run my Save() function when a player disconencts from the server? (Multiplayer game)

Actually, I can’t even get this to work:

public override void OnClientDisconnect(NetworkConnection conn)
{
base.OnClientDisconnect(conn);
print("Client disconnected");
}

Try Debug.Log to see if the method is actually called. I’ve found some discussion wether print is always the best choice. Just to make sure.
I’m not very much into Unity Networking, but why do you call OnClientDisconnect from OnClientDisconnect?
Once you’ve got that sorted out you just need a reference to your saving system and call Save, which is pretty straight forward:
On your - let’s say - “Saving” class have a public static Saving svg variable that you assign itself to in the Start() function. You can then call it from anywhere by Saving.svg.Save()

public static Saving svg;

void Start()
{
  svg = this;
}

public void Save()
{
}

Oh my lord, it seems I’ve had the stupidest mistake.

I did try using that design for calling the Save() function. But in void Start() I wrote

Saving svg = this;
instead of
svg = this;

So yeah, wonderful to have someone else look at your code or just look at someone elses ^^

Thanks a bunch, I was becoming insane

However, still can’t run the debug messages in OnClientConnect / Disconnect / OnServerDisconnect