RustTip

OnPlayerSetInfo

OxideCarbonPlayer

Called when player set info occurs.

void OnPlayerSetInfo(Network.Connection connection, string key, string val)
void OnPlayerSetInfo(object connection, string key, string val)
Works — the game method in this build is the one the hook was written for.

Parameters

connection
Network.Connection
key
string
val
string

Return value

voidThe return value is ignored — the hook only notifies.

Example

private void OnPlayerSetInfo(Network.Connection connection, string key, string val)
{
    Puts("OnPlayerSetInfo");
}

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

Injection point 1

Rust.opj (Oxide)
void ServerMgr.ClientReady(Network.Message)

Passes: Network.Connection connection, string key, string val

WorksReturnBehavior: ContinueArgumentBehavior: UseArgumentString (a0.connection, l3.name, l3.value)Assembly-CSharp.dll

Where it is called (this branch's game code)

// …
	return;
}
using (packet.read.UseRepeatedElementLimit(512))
{
	using (ClientReady clientReady = packet.read.Proto<ClientReady>())
	{
		foreach (ClientReady.ClientInfo item in clientReady.clientInfo)
		{
			Interface.CallHook("OnPlayerSetInfo", packet.connection, local3.name, local3.value);
			packet.connection.info.Set(item.name, item.value);
		}
		packet.connection.globalNetworking = clientReady.globalNetworking;
		packet.connection.state = Network.Connection.State.Connected;
		connectionQueue.JoinedGame(packet.connection);
		Analytics.Azure.OnPlayerConnected(packet.connection);
		AddPartyMembersToTeam(packet.connection, clientReady.party);
		using (TimeWarning.New("ClientReady"))
// …

Injection point 2

Rust.opj (Oxide)
void BasePlayer.SetInfo(string, string)

Passes: object connection, string key, string val

WorksReturnBehavior: ContinueArgumentBehavior: UseArgumentString (this.net.connection, a0, a1)Assembly-CSharp.dll

Where it is called (this branch's game code)

public virtual void SetInfo(string key, string val)
{
	if (IsConnected)
	{
		Interface.CallHook("OnPlayerSetInfo", this.net.connection, key, val);
		net.connection.info.Set(key, val);
	}
}

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.