Skip to content
RustPluginGenerator

OnEngineReverse

OnEngineReverse is called when a player toggles the reverse direction of a boat's SmallEngine, before Oxide checks boat ownership and applies the reverse flag.

Signature
object OnEngineReverse(SmallEngine smallEngine, BasePlayer player)

Parameters

Hook parameters
ParameterTypeDescription
smallEngineSmallEngineThe SmallEngine entity whose reverse state is being toggled. Use it to read InReverse, check ownership, or inspect its parent boat via GetParentEntity().
playerBasePlayerThe BasePlayer who sent the reverse request. May be null on unexpected RPC paths, so always null-check it before using.

Return value

Returning null lets the game continue with its normal authorization checks and reverse toggling. Returning any non-null object makes SV_ToggleReverse return immediately, so the reverse flag is never changed and no network update is sent.

How it works

This hook fires inside SmallEngine.SV_ToggleReverse, the server-side handler for the RPC a player sends when they press the reverse control on a boat. It runs before the game verifies that the player is authorized on the boat's child entity and that the engine actually belongs to an interactable player boat, and before the reverse flag is flipped.

smallEngine is the engine being toggled; player is the requester. Returning a non-null value from the hook returns the original method early, which cancels the reverse toggle entirely. Returning null lets the vanilla authorization and reverse logic run normally.

The hook fires per request, so it can be hit often during maneuvering. Do not call Puts or PrintWarning here. You can read smallEngine.InReverse to know the current state (it reflects the state before the toggle is applied). Since the hook fires before authorization, it is not itself a security boundary for ownership checks, but it is a convenient place to add cooldowns or per-player restrictions.

Example plugin: Rate-limit and lock reverse for unauthorized players

EngineReverseGuard.cs
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Oxide.Core;
using UnityEngine;

namespace Oxide.Plugins
{
    [Info("Engine Reverse Guard", "RustPluginGenerator", "1.0.0")]
    [Description("Rate-limits and optionally restricts reverse toggles on player boats")]
    public class EngineReverseGuard : RustPlugin
    {
        private class PluginConfig
        {
            [JsonProperty("Require boat authorization")]
            public bool RequireAuth { get; set; } = true;

            [JsonProperty("Minimum seconds between toggles")]
            public float CooldownSeconds { get; set; } = 0.4f;
        }

        private PluginConfig config;
        private readonly Dictionary<ulong, float> lastToggle = 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);

        private object OnEngineReverse(SmallEngine smallEngine, BasePlayer player)
        {
            if (smallEngine == null || player == null) return null;

            var boat = smallEngine.GetParentEntity();
            if (boat == null) return null;

            if (config.RequireAuth)
            {
                var privilege = boat.GetBuildingPrivilege();
                if (privilege != null && !privilege.IsAuthed(player))
                    return false;
            }

            ulong userId = player.userID.Get();
            float now = Time.realtimeSinceStartup;
            float last;
            if (lastToggle.TryGetValue(userId, out last) && now - last < config.CooldownSeconds)
                return false;

            lastToggle[userId] = now;
            return null;
        }

        private void Unload()
        {
            lastToggle.Clear();
        }
    }
}

The plugin blocks reverse toggles for players who are not authorized on the boat the engine belongs to, and rate-limits toggles to one per configurable interval. In OnEngineReverse it first null-checks the engine and player. It resolves the parent boat with GetParentEntity(), then looks for a building privilege on that boat to confirm authorization. If the player fails the check it returns a non-null value, which cancels the toggle. Otherwise it records the last toggle time per player id and blocks rapid repeats. The config exposes the cooldown in seconds and whether the authorization check is enabled.

Common use cases

  • Anti-grief reverse spam

    Throttle repeated reverse toggles from the same player to reduce network churn and prevent patterns where players exploit rapid toggling for movement quirks.

  • Restrict reverse to authorized crew

    Block reverse requests from players who are not authorized on the boat, useful on servers where boats are shared between teams and only keyholders should control engines.

  • Log or count maneuvers

    Increment a per-player counter or record timestamps for analytics without blocking the toggle; return null so normal behavior continues.

Pitfalls

  • Fires before vanilla authorization

    The hook runs before the game checks IsPlayerAuthedOnChildEntity and IsChildOfInteractablePlayerBoat. Unauthorized players can still reach your hook, so never assume player is legitimate just because it is non-null.

  • Returning a value cancels the toggle

    Any non-null return stops the original method. If you only want to observe, always return null; returning true or an object will silently prevent the engine from reversing.

  • Do not spam the console

    This hook can fire many times per session during normal boat handling. Avoid Puts or PrintWarning inside it and use throttled messaging or counters instead.

Build a plugin with OnEngineReverse

Describe what should happen and get a compiled plugin that uses this hook.

Prompt: Anti-grief reverse spam using the OnEngineReverse hook, with a config file and a permission
Generate this plugin

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 OnEngineReverse

Generate