OnMissionAssigned
OnMissionAssigned is called after the server has fully assigned a mission to a player, including starting it and marking the mission list dirty. It fires at the end of BaseMission.AssignMission, before the method returns true.
void OnMissionAssigned(BaseMission mission, IMissionProvider provider, BasePlayer assignee)Parameters
| Parameter | Type | Description |
|---|---|---|
mission | BaseMission | The BaseMission definition that was just assigned, holding the mission name, provider reference and objective array. |
provider | IMissionProvider | The IMissionProvider that owns and delivered the mission, useful for telling which mission source (e.g. a mission board) issued it. |
assignee | BasePlayer | The BasePlayer who received the mission. Check for null and IsNpc before treating him as a real player. |
Return value
The return value is ignored. AssignMission returns true regardless of what the hook returns, so returning nothing or any value makes no difference to the assignment.
How it works
The hook is injected at the end of BaseMission.AssignMission, after mission.MissionStart, SetActiveMissionIndex and MissionsDirty have already run. By the time it fires the mission is live for the player, so you cannot use it to cancel or vet an assignment - the assignment has already happened and the method is about to return true.
mission is the BaseMission definition, useful for reading mission.name or inspecting objectives. provider is the IMissionProvider that issued it, which helps when a server runs multiple mission sources and you only want to react to one. assignee is the receiving player.
You can narrow the dispatch by declaring assignee as a more specific type, but there is no useful subclass check here in practice: declare it as BasePlayer and guard with IsNpc. Since the hook fires once per assignment (not per tick), lightweight notifications, UI refreshes or data writes are fine, but heavy work should be deferred with a timer.
Example plugin: Announce and log new mission assignments
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Oxide.Core;
using UnityEngine;
namespace Oxide.Plugins
{
[Info("Mission Assignment Notifier", "RustPluginGenerator", "1.0.0")]
[Description("Announces and logs mission assignments made by mission providers")]
public class MissionAssignmentNotifier : RustPlugin
{
private const string PermUse = "missionassignmentnotifier.use";
private PluginConfig config;
private class PluginConfig
{
[JsonProperty("Broadcast to all players")]
public bool Broadcast { get; set; } = true;
[JsonProperty("Log assignments to server console")]
public bool LogToConsole { get; set; } = true;
}
protected override void LoadDefaultConfig() => config = new PluginConfig();
protected override void LoadConfig()
{
base.LoadConfig();
try
{
config = Config.ReadObject<PluginConfig>();
if (config == null) throw new Exception();
}
catch
{
PrintWarning("Configuration file is invalid, using defaults");
LoadDefaultConfig();
}
SaveConfig();
}
protected override void SaveConfig() => Config.WriteObject(config);
protected override void LoadDefaultMessages()
{
lang.RegisterMessages(new Dictionary<string, string>
{
["Broadcast"] = "{0} was assigned the mission: {1}",
["Private"] = "You received a new mission: {0}",
["Unknown"] = "Unknown Mission"
}, this);
}
private void Init()
{
permission.RegisterPermission(PermUse, this);
}
private string Msg(string key, string userId = null, params object[] args)
=> string.Format(lang.GetMessage(key, this, userId), args);
private void OnMissionAssigned(BaseMission mission, IMissionProvider provider, BasePlayer assignee)
{
if (assignee == null || assignee.IsNpc || !assignee.IsConnected)
return;
var missionName = mission != null && !string.IsNullOrEmpty(mission.name)
? mission.name
: Msg("Unknown", assignee.UserIDString);
if (config.LogToConsole)
{
var providerName = provider != null ? provider.GetType().Name : "unknown provider";
Debug.Log($"[MissionAssignmentNotifier] {assignee.displayName} ({assignee.UserIDString}) received '{missionName}' from {providerName}");
}
assignee.ChatMessage(Msg("Private", assignee.UserIDString, missionName));
if (!config.Broadcast)
return;
Server.Broadcast(string.Format(lang.GetMessage("Broadcast", this), assignee.displayName, missionName));
}
}
}The plugin listens for OnMissionAssigned, skips NPCs and null assignees, then broadcasts a configurable chat line naming the player and mission. It also sends the assignee a private confirmation through the language system and writes a short line to the server log. LoadDefaultConfig seeds a Broadcast to all players toggle and the Mission name style message, both editable in oxide/config. The mission name comes from mission.name, falling back to a placeholder when empty. Because the hook fires once per assignment, the broadcast and logging cost is negligible.
Common use cases
Team-wide mission pings
When a player receives a mission, look up
assignee.currentTeamviaRelationshipManager.ServerInstance.FindTeamand message each online member so a group knows a mission started.Mission statistics tracking
Increment per-player counters when a mission is assigned and persist them to
oxide/data, giving admins data on which players accept the most missions.UI refresh on assignment
Push a CUI panel to the assignee showing the mission name and objective count so the player sees an in-game prompt without opening the mission menu.
Pitfalls
Cannot cancel the mission
The hook fires after MissionStart and MissionsDirty, so returning any value or doing work here cannot prevent the assignment. Use
CanAssignMissionfor vetting.NPCs and null assignees
Guard against a null
assigneeand skip entities whereIsNpcis true, otherwise your notification could target an AI or throw a NullReferenceException.Do not spam chat per assignment
If missions are assigned frequently (e.g. auto-issued dailies), a broadcast per assignment will flood chat. Gate the broadcast behind a config toggle or rate-limit it.
Build a plugin with OnMissionAssigned
Describe what should happen and get a compiled plugin that uses this hook.
Edit the prompt on the next screen. 2 free plugins a month, no card.
Last updated Oct 26, 2026. Found a mistake? Email support@rustplugingenerator.com.
Build a plugin with OnMissionAssigned
Generate