RustTip

OnNpcConversationRespond

OxideCarbonNPC

Called when npc conversation respond occurs.

object OnNpcConversationRespond(NPCTalking nPCTalking, BasePlayer local0, ConversationData local6, ConversationData.ResponseNode local20)
Works — the game method in this build is the one the hook was written for.

Parameters

nPCTalking
NPCTalking
local0
BasePlayer
local6
ConversationData
local20
ConversationData.ResponseNode

Return value

objectReturn non-null to cancel the game action.

Example

object — you can affect the game: return a value to change or cancel the action.

private object OnNpcConversationRespond(NPCTalking nPCTalking, BasePlayer local0, ConversationData local6, ConversationData.ResponseNode local20)
{
    Puts("OnNpcConversationRespond");

    // change nothing — the game continues as usual
    return null;

    // to affect the game:
    // return false; // non-null cancels the game action
}

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

Injection point

Rust.opj (Oxide)
void NPCTalking.Server_ResponsePressed(BaseEntity.RPCMessage)

Passes: NPCTalking nPCTalking, BasePlayer local0, ConversationData local6, ConversationData.ResponseNode local20

WorksReturnBehavior: ExitWhenValidTypeArgumentBehavior: UseArgumentString (this, l0, l6, l20)Assembly-CSharp.dll

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

// …
}
if (abstractSpeechNodeData is ConversationData.MissionPreviewSpeechNodeData && this is NPCSimpleMissionProvider && num2 == 0 && missionProvider != null && missionProvider.TryGetMission(missionId, out var mission2) && player.Server_CanAcceptMission(missionProvider, mission2))
{
	TryAssignMissionToPlayer(mission2, player);
}
ConversationData.ResponseNode responseNode = abstractSpeechNodeData.responses[num2];
if (responseNode != null)
{
	if (Interface.CallHook("OnNpcConversationRespond", this, player, conversationFor, responseNode) != null)
	{
		return;
	}
	if (responseNode.conditions.Length != 0)
	{
		UpdateFlags();
	}
	bool flag2 = responseNode.PassesConditions(player, this);
// …

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.