OnEntityMounted
OnEntityMounted is called after a player has successfully been placed on a BaseMountable, fired from BaseMountable.MountPlayer once the mount has fully completed.
void OnEntityMounted(BaseMountable mountable, BasePlayer player)Parameters
| Parameter | Type | Description |
|---|---|---|
mountable | BaseMountable | The BaseMountable entity the player just mounted: a chair, a ModularCar seat, a boat helm, a horse saddle, an APC turret and so on. Use its position and type to decide what happened. |
player | BasePlayer | The BasePlayer that finished the mount. Always connected at this point, but check IsConnected and IsNpc before applying player-only logic. |
Return value
The hook is called without using its return value, so whatever your method returns is ignored. Returning null or any object has no effect on the mount and the original code path always continues.
How it works
The hook fires inside BaseMountable.MountPlayer after the player has been attached to the seat, their view angles overridden and their network update sent. It runs before gesture handling, so it covers every successful mount: sitting in a chair, entering a car seat, taking a boat helm, mounting a horse or APC. It does not fire when CanMountEntity or CanSwapToSeat blocked the mount, because MountPlayer never runs in that case.
mountable is the seat entity itself. Cast it to a known type (ModularCar, MiniCopter, BaseBoat, BaseMountable with a custom prefab) to distinguish vehicles, and use mountable.transform.position for distance checks. player is the occupant; player.GetMounted() already returns the mountable when the hook runs, and player.isMounted is true.
Declaring BaseMountable is already the base type, so narrowing the parameter has no practical benefit here; instead branch on the runtime type inside the hook. Because this fires at most once per mount action, moderate work (chat message, CUI panel, timer setup) is acceptable, but keep it cheap.
Example plugin: Chat notification and restrictions for specific vehicle seats
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Oxide.Core;
using UnityEngine;
namespace Oxide.Plugins
{
[Info("MountAnnouncer", "RustPluginGenerator", "1.0.0")]
[Description("Sends a localized chat notice when a player mounts a vehicle seat")]
public class MountAnnouncer : RustPlugin
{
private const string PermNotify = "mountannouncer.notify";
private PluginConfig config;
private class PluginConfig
{
[JsonProperty("Announce car mounts")]
public bool AnnounceCars { get; set; } = true;
[JsonProperty("Announce boat mounts")]
public bool AnnounceBoats { get; set; } = true;
[JsonProperty("Announce helicopter mounts")]
public bool AnnounceHelicopters { get; set; } = true;
[JsonProperty("Announce horse mounts")]
public bool AnnounceHorses { 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>
{
["Mount.Car"] = "You took a seat in a vehicle. Press USE to exit.",
["Mount.Boat"] = "You took the helm of a boat. Press USE to step off.",
["Mount.Heli"] = "You boarded a helicopter. Press USE to exit.",
["Mount.Horse"] = "You mounted a horse. Press USE to dismount."
}, 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(PermNotify, this);
}
private void OnEntityMounted(BaseMountable mountable, BasePlayer player)
{
if (mountable == null || player == null) return;
if (!player.IsConnected || player.IsNpc) return;
if (!permission.UserHasPermission(player.UserIDString, PermNotify)) return;
string label = GetMountLabel(mountable, player);
if (label == null) return;
player.ChatMessage(Msg("Mount." + label, player.UserIDString));
}
private string GetMountLabel(BaseMountable mountable, BasePlayer player)
{
if (mountable is ModularCar || mountable.GetComponentInParent<ModularCar>() != null)
return config.AnnounceCars ? "Car" : null;
if (mountable is BaseBoat || mountable.GetComponentInParent<BaseBoat>() != null)
return config.AnnounceBoats ? "Boat" : null;
if (mountable is BaseHelicopter || mountable.GetComponentInParent<BaseHelicopter>() != null)
return config.AnnounceHelicopters ? "Heli" : null;
if (mountable is RidableHorse || mountable.GetComponentInParent<RidableHorse>() != null)
return config.AnnounceHorses ? "Horse" : null;
return null;
}
}
}The plugin listens for every successful mount and checks the entity type. When a player boards a car, boat, minicopter or horse, it sends a localized chat line telling them how to exit with the use key. GetMountLabel maps the runtime type to a short human name used in the message. A config flag lets admins disable announcements for seats they find noisy, and CanMountEntity-style rules are not touched here, so a blocked mount never reaches this hook at all. All text goes through lang, so messages can be translated without recompiling.
Common use cases
Refund or block vehicle usage for spectators
Detect when a player mounts a car or heli while a custom event is running and inform the event handler. The event plugin can then decide to dismount or flag the player.
Vehicle entry announcements
Broadcast to a team or to chat when someone takes a seat in a shared vehicle, useful on PvE or roleplay servers where knowing who drives matters.
Seat-based UI or buffs
Open a small CUI panel with controls or rules the first time a player sits in a custom vehicle seat, and close it in OnEntityDismounted.
Pitfalls
Does not fire for blocked mounts
If another hook such as CanMountEntity returned false, MountPlayer is never called and OnEntityMounted will not run. Put rejection logic in CanMountEntity instead.
Passengers and drivers look identical
The hook does not tell you which seat was taken. Cast the mountable to ModularCar or similar and inspect the seat index if you need to differentiate the driver.
Player may already be dismounted by the time a timer runs
Scheduling delayed work is fine, but re-check player.GetMounted() == mountable inside the callback, since the player can exit immediately.
Build a plugin with OnEntityMounted
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 OnEntityMounted
Generate