OnPlayerWantsDismount
OnPlayerWantsDismount is called when a mounted player presses the dismount key and the mount has already confirmed a valid exit position. Returning a non-null value cancels the dismount.
object OnPlayerWantsDismount(BasePlayer player, BaseMountable mountable)Parameters
| Parameter | Type | Description |
|---|---|---|
player | BasePlayer | The player who sent the dismount request. Treat it as possibly null in code even though normal RPC flow supplies a valid BasePlayer. |
mountable | BaseMountable | The BaseMountable the player is currently sitting on (chair, minicopter seat, car seat, horse saddle). Use it to check the vehicle type or its owner. |
Return value
Returning null lets the dismount proceed (subject to the restraint check). Returning any non-null object cancels the request and the player stays mounted; the value itself is not used, so a dummy true or false works as a block. Because the check is == null, returning false still blocks — only a true null allows the dismount.
How it works
The hook fires inside BaseMountable.RPC_WantsDismount, the server-side RPC a client sends when the player presses the dismount key or is pushed into a dismount request. The code first checks HasValidDismountPosition; if no valid spot exists it runs OnPlayerDismountFailed instead, so this hook only runs when the player could actually get off. Right after this hook returns null, the game also verifies the player is not restrained before calling AttemptDismount. Use player to identify who is leaving and mountable to inspect what they are leaving — mountable.ShortPrefabName, mountable.OwnerID, or casting to MiniCopter, ModularCar, BaseBoat or similar. Because both parameters are already typed as BasePlayer and BaseMountable, you cannot narrow them and still receive calls in this signature; narrowing to a subclass such as MiniCopter would skip dismounts from every other seat type. The hook fires once per dismount request, so keep the body cheap.
Example plugin: Stop players dismounting mid-air from a minicopter
using System.Linq;
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Oxide.Core;
using UnityEngine;
namespace Oxide.Plugins
{
[Info("No Air Dismount", "RustPluginGenerator", "1.0.0")]
[Description("Prevents players from leaving a minicopter seat while too high above the ground.")]
public class NoAirDismount : RustPlugin
{
private const string PermBypass = "noairdismount.bypass";
private PluginConfig config;
private class PluginConfig
{
[JsonProperty("Minimum altitude to block (metres)")]
public float MinAltitude = 8f;
[JsonProperty("Allow permission holders to bypass")]
public bool AllowBypass = 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>
{
["TooHigh"] = "You cannot leave the seat {0} metres above the ground."
}, 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 object OnPlayerWantsDismount(BasePlayer player, BaseMountable mountable)
{
if (player == null || mountable == null) return null;
if (player.IsWounded() || player.IsDead()) return null;
if (config.AllowBypass && permission.UserHasPermission(player.UserIDString, PermBypass))
return null;
if (mountable.ShortPrefabName == null) return null;
string prefab = mountable.ShortPrefabName.ToLower();
if (!prefab.Contains("minicopter") && !prefab.Contains("scraptransporthelicopter"))
return null;
if (mountable.transform == null || player.transform == null) return null;
float ground = TerrainMeta.HeightMap.GetHeight(player.transform.position);
float altitude = player.transform.position.y - ground;
if (altitude <= config.MinAltitude) return null;
player.ChatMessage(Msg("TooHigh", player.UserIDString, Mathf.RoundToInt(altitude)));
return true;
}
}
}The plugin hooks OnPlayerWantsDismount and checks the mountable's ShortPrefabName for minicopter or scraptransporthelicopter (case-insensitive). If the player is wounded or dead, or either transform is missing, the check is skipped. Otherwise it measures the player's height above the terrain using TerrainMeta.HeightMap.GetHeight. If that altitude exceeds the configured minimum, the hook returns true to block the dismount and sends a localized warning. Config fields control the minimum altitude and whether permission holders with noairdismount.bypass may bypass the check. The message text lives in the language file so it can be localized by editing the oxide/lang entry.
Common use cases
Prevent dismounting over unguarded loot
Block dismounts unless the player is inside a building privilege zone, so raiders cannot hop off a minicopter directly above a base wall.
Lock passengers into a vehicle
Return non-null while a vehicle event is running so participants cannot leave the ModularCar seat until the round ends.
Restrict dismounting while wounded or hot
Check
player.IsWounded()or the player's temperature and force them to stay seated until they recover.
Pitfalls
Returning false does not allow
Oxide checks whether the return value is null. Returning
falseblocks the dismount exactly liketruedoes. Return plainnullto let the player off.Not the same as OnPlayerDismountFailed
If there is no valid exit position, Rust never calls this hook. Your block logic will not run in that case, so do not rely on it to catch all forced dismounts.
Physics and ejection bypass this hook
Vehicle destruction, seat ejection and admin Kill commands do not route through this RPC, so a block here will not keep a player on a destroyed mount.
Build a plugin with OnPlayerWantsDismount
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 OnPlayerWantsDismount
Generate