OnVehiclePush
OnVehiclePush is called when a player sends a push request for a vehicle they are not mounted on, before the game applies the calorie cost and push impulse.
object OnVehiclePush(BaseVehicle vehicle, BasePlayer player)Parameters
| Parameter | Type | Description |
|---|---|---|
vehicle | BaseVehicle | The BaseVehicle instance the player is trying to push. Use it to check type (e.g. ModularCar, MiniCopter), owner, position or whether it recently moved. |
player | BasePlayer | The BasePlayer sending the push request. Use it for permission checks, cooldowns, team/owner comparisons or chat/UI feedback. |
Return value
Returning null lets the push continue: the game subtracts 3 calories from the player and applies the rigidbody push impulse. Returning any non-null value (for example true or an empty string) stops the original code path, so no calories are spent and the vehicle is not pushed.
How it works
The hook fires inside BaseVehicle.RPC_WantsPush, which the client calls when the player holds the push key while standing next to a vehicle they are not riding. By the time the hook runs, the game has already checked that the player is unmounted, that the vehicle is not RecentlyPushed, that CanPushNow(player) is true, that a rigidbody exists, and that the player is allowed to access the vehicle (owner-only vehicles reject non-owners before this point).
Declaring BaseVehicle gives you every pushable vehicle. Narrow it to a subtype such as ModularCar or MiniCopter if you only care about certain vehicles; Oxide skips the call for any vehicle that is not an instance of the declared type, so the push proceeds untouched.
The hook is a cheap place to enforce rules: return a non-null value to cancel the push silently, or let it through and the game subtracts 3 calories and applies the push force. There is no built-in cooldown or message when you block, so send your own feedback if needed. Note that players can spam the RPC, so keep the body allocation-free and avoid logging.
Example plugin: Require permission and a push cooldown for vehicles
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Oxide.Core;
using UnityEngine;
namespace Oxide.Plugins
{
[Info("Vehicle Push Control", "RustPluginGenerator", "1.0.0")]
[Description("Requires a permission and enforces a cooldown for vehicle pushes")]
public class VehiclePushControl : RustPlugin
{
private const string PermUse = "vehiclepushcontrol.use";
private class PluginConfig
{
[JsonProperty("Require permission to push")]
public bool RequirePermission { get; set; } = true;
[JsonProperty("Push cooldown in seconds")]
public float PushCooldown { get; set; } = 1.5f;
}
private PluginConfig config;
private readonly Dictionary<ulong, float> lastPush = new Dictionary<ulong, float>();
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>
{
["NoPermission"] = "You do not have permission to push vehicles.",
["Cooldown"] = "Wait a moment before pushing again."
}, 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(PermUse, this);
}
private object OnVehiclePush(BaseVehicle vehicle, BasePlayer player)
{
if (vehicle == null || player == null || player.IsNpc) return null;
if (config.RequirePermission && !permission.UserHasPermission(player.UserIDString, PermUse))
{
player.ChatMessage(Msg("NoPermission", player.UserIDString));
return true;
}
float now = Time.realtimeSinceStartup;
float last;
if (lastPush.TryGetValue(player.userID, out last) && now - last < config.PushCooldown)
{
player.ChatMessage(Msg("Cooldown", player.UserIDString));
return true;
}
lastPush[player.userID] = now;
return null;
}
private void Unload()
{
lastPush.Clear();
}
}
}The plugin blocks every push unless the player has the vehiclepushcontrol.use permission, then enforces a per-player cooldown between accepted pushes so a held key cannot drain metabolism or shove vehicles around. OnVehiclePush returns true to cancel the push when the permission is missing or the cooldown is still active, and returns null to let the game apply the normal calorie cost and impulse. The cooldown dictionary stores timestamps from Time.realtimeSinceStartup, is trimmed when stale, and is cleared on unload. Both messages come from the language file, and a config toggle lets admins disable the permission check while keeping the cooldown.
Common use cases
Permission-gated pushing
Only allow players with a specific permission to push vehicles, so restricted event areas or roleplay servers can keep vehicles in place.
Anti-spam cooldown
Throttle accepted pushes per player to stop clients from spamming
RPC_WantsPushand burning calories or nudging vehicles continuously.Restrict pushing by vehicle type or zone
Declare a narrower parameter type (e.g.
ModularCar) or check the vehicle position against a zone to block pushes in safe zones while leaving other vehicles unaffected.
Pitfalls
Cancelling is silent
Returning a non-null value stops the push without any message to the player. Send your own chat or UI feedback from the hook body.
Narrowing hides other vehicles
If you declare
ModularCarinstead ofBaseVehicle, Oxide never calls your hook for boats, helicopters or other vehicles, so your rules silently do not apply there.The hook runs after the game's own checks
RecentlyPushed, CanPushNow, owner-only access and mounted state are evaluated before the hook. A vehicle rejected by the game never reaches
OnVehiclePush, so you cannot use it to relax those rules.
Build a plugin with OnVehiclePush
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 OnVehiclePush
Generate