RustTip

OnEntitySaved

OxideCarbonGlobal

Called when an entity's state is serialized and written to the save stream.

void OnEntitySaved(BaseNetworkable networkable, BaseNetworkable.SaveInfo info)
Works — the game method in this build is the one the hook was written for.

Parameters

networkable
BaseNetworkable
info
BaseNetworkable.SaveInfo

Return value

voidThe return value is ignored — the hook only notifies.

Example

private void OnEntitySaved(BaseNetworkable networkable, BaseNetworkable.SaveInfo info)
{
    Puts("OnEntitySaved");
}

Works in both Oxide and Carbon: Carbon loads Oxide plugins as is.

Where it is called

Oxide core (Oxide.Rust)
RustCore::IOnEntitySaved(BaseNetworkable baseNetworkable, BaseNetworkable.SaveInfo saveInfo)

Oxide core code — the hook is called from here

private void IOnEntitySaved(BaseNetworkable baseNetworkable, BaseNetworkable.SaveInfo saveInfo)
{
    // Only call when saving for the network since we don't expect plugins to want to intercept saving to disk
    if (!serverInitialized || saveInfo.forConnection == null)
    {
        return;
    }

    Interface.CallHook("OnEntitySaved", baseNetworkable, saveInfo);
}

Injection point

Carbon
void BaseNetworkable.ToStream(System.IO.Stream stream, BaseNetworkable.SaveInfo saveInfo)
WorksAssembly-CSharp

Sources: Rust.opj from OxideMod/Oxide.Rust (MIT) and hook metadata of the Carbon documentation (MIT). Method code is decompiled from this branch's server.