OnApplicationCommand
OnApplicationCommand is called by Oxide's command router when a player runs a chat command while not connected, so the command is not handled by the normal chat command path.
void OnApplicationCommand(BasePlayer player, string cmd, string[] args)Parameters
| Parameter | Type | Description |
|---|---|---|
player | BasePlayer | The BasePlayer who sent the command. Because this hook only fires for disconnected players, the player is a saved/offline character or a player whose connection has just dropped; net.connection is null. |
cmd | string | The parsed command name without the chat prefix, for example `kit` from `/kit starter`. |
args | string[] | Array of the whitespace-separated arguments after the command name; may be empty but is not null when parsed. |
Return value
The return value is ignored at both call sites. Returning a value or null has no effect on the command; the router always returns after calling the hook, so the command is never dispatched anywhere.
How it works
Oxide parses any message a player sends through Rust's command router. When the player is still connected, the command continues into the normal dispatch and Oxide fires OnPlayerCommand / OnUserCommand instead. This hook only fires on the branch where BasePlayer.IsConnected is false, for example a queued message from Rust+ or a command processed after the connection dropped. Both versions of the hook (BasePlayer and IPlayer) are called back to back, then the method returns, so no chat command handler, console command or game command is ever executed for that message.
cmd is the parsed command word and args holds the remaining tokens, matching the same parser used for regular chat commands. The player object can be a player who is mid-disconnect or a saved character; treat it as unreliable and null-check it. Declaring the parameter as IPlayer instead of BasePlayer uses Oxide's dispatch to receive the covalence player wrapper, which is useful when you already work with IPlayer APIs. Since normal commands never run here, this hook is mostly useful for sending players feedback about commands they tried during a disconnect.
Other signatures
Oxide also calls OnApplicationCommand from other places in the game with these parameter types. Declare the overload you need, or several:
void OnApplicationCommand(IPlayer iplayer, string cmd, string[] args)
Example plugin: Reply to commands sent by disconnected players
using System.Linq;
using UnityEngine;
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Oxide.Core;
namespace Oxide.Plugins
{
[Info("Disconnected Command Notifier", "RustPluginGenerator", "1.0.0")]
[Description("Tells players that chat commands sent while disconnected were not executed.")]
public class DisconnectedCommandNotifier : RustPlugin
{
private const string PermBypass = "disconnectedcommandnotifier.bypass";
private PluginConfig config;
private readonly Dictionary<ulong, double> lastReply = new Dictionary<ulong, double>();
private class PluginConfig
{
[JsonProperty("Reply cooldown in seconds")]
public float ReplyCooldown { get; set; } = 15f;
[JsonProperty("Ignore these commands")]
public List<string> IgnoredCommands { get; set; } = new List<string> { "help", "info" };
}
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>
{
["NotExecuted"] = "Your command '{0}' was not executed because you were not connected. Please try again after reconnecting."
}, this);
}
private string Msg(string key, string userId = null, params object[] args) => string.Format(lang.GetMessage(key, this, userId), args);
private void Init()
{
permission.RegisterPermission(PermBypass, this);
}
private void OnApplicationCommand(BasePlayer player, string cmd, string[] args)
{
if (player == null || string.IsNullOrEmpty(cmd)) return;
if (player.net == null || player.net.connection == null) return;
if (permission.UserHasPermission(player.UserIDString, PermBypass)) return;
if (config.IgnoredCommands != null && config.IgnoredCommands.Contains(cmd.ToLowerInvariant())) return;
ulong userId = player.userID.Get();
double now = UnityEngine.Time.realtimeSinceStartup;
double last;
if (lastReply.TryGetValue(userId, out last) && now - last < config.ReplyCooldown) return;
lastReply[userId] = now;
player.ChatMessage(Msg("NotExecuted", player.UserIDString, cmd));
}
private void Unload()
{
lastReply.Clear();
}
}
}The plugin listens on OnApplicationCommand and answers players who ran a chat command while their connection was down. It whitelists a few safe command names in the config so admins can decide which ones get a polite reply. For every other command it sends a lang message telling the player the command did not run because they were disconnected. Because the hook is only reachable when the player is not connected, the plugin guards against the null connection and uses SendConsoleCommand("chat.add", ...) style output only when the player is still reachable through a live network connection, otherwise it silently skips. A message cooldown per user id keeps repeated app commands from spamming.
Common use cases
Explain silent commands to mobile players
Tell players that a command typed during a disconnect or from the Rust+ app was not executed, so they know to resend it after reconnecting.
Audit app-originated commands
Count or record which commands arrive while a player is disconnected to spot automation or tooling that talks to the server outside the game client.
Fallback routing for custom commands
Re-process a small set of your own plugin commands manually for disconnected players when the action is safe to run without a live client.
Pitfalls
Normal commands never reach this hook
Only the disconnected branch calls it. If you test with a connected player and nothing happens, that is expected; use OnPlayerCommand for connected commands.
The player may not be usable
Since IsConnected is false, net.connection is null and player-facing APIs that require a connection can fail. Null-check the player and avoid sending UI or chat that requires an active connection.
Both overloads fire
Oxide calls the BasePlayer version and the IPlayer version for the same command. If you implement both overloads in one plugin, guard against handling the same command twice.
Build a plugin with OnApplicationCommand
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 OnApplicationCommand
Generate