Skip to content
RustPluginGenerator

OnElevatorCall

OnElevatorCall is called for each elevator car the caller considers while a call button is pressed, before the game asks that car to travel to the caller's floor.

Signature
object OnElevatorCall(Elevator elevator, Elevator elevatorEnt)

Parameters

Hook parameters
ParameterTypeDescription
elevatorElevatorThe elevator caller instance that started the call sequence. Useful for reading the button floor and the calling context; null-check it before use.
elevatorEntElevatorThe candidate elevator car the caller is about to request a move on. Returning non-null for this car blocks its move request.

Return value

Return null (or nothing) to let the game proceed and send the evaluated car to the caller's floor. Return any non-null value to cancel that move request for this car, including returning false — the value is not interpreted, only its presence matters.

How it works

This hook fires inside the elevator's call callback, once per candidate car, at the moment the game checks whether that car is at the top and should be sent to the calling floor. The elevator parameter is the caller and elevatorEnt is the specific car being evaluated. Because the request only proceeds when the hook returns null, returning anything non-null skips RequestMoveLiftTo for that car and that call attempt. Declaring elevatorEnt as a more specific type is not useful here since the game only passes Elevator instances; narrowing would simply stop the hook from being involved. Practical uses are gating elevator calls by permission, cooldown, base authorization, or building state. Note that the callback only runs for cars whose IsTop is true, so a blocked car stays idle rather than moving elsewhere. Keep the handler cheap: it can run for multiple cars in a single button press and fires on every call in a busy base.

Example plugin: Restrict elevator calls to authorized players

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

namespace Oxide.Plugins
{
    [Info("Elevator Call Guard", "RustPluginGenerator", "1.0.0")]
    [Description("Restricts elevator calls to players holding a configured permission")]
    public class ElevatorCallGuard : RustPlugin
    {
        private const string PermUse = "elevatorcallguard.use";

        private PluginConfig config;

        private class PluginConfig
        {
            [JsonProperty("Require permission to call elevators")]
            public bool RequirePermission = true;

            [JsonProperty("Cooldown between calls in seconds (0 disables)")]
            public float CooldownSeconds = 0f;
        }

        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 are not allowed to call this elevator.",
                ["Cooldown"] = "Wait {0} more seconds before calling the elevator again."
            }, this);
        }

        private string Msg(string key, string userId = null, params object[] args) =>
            string.Format(lang.GetMessage(key, this, userId), args);

        private readonly Dictionary<ulong, float> lastCall = new Dictionary<ulong, float>();

        private void Init()
        {
            permission.RegisterPermission(PermUse, this);
        }

        private object OnElevatorCall(Elevator elevator, Elevator elevatorEnt)
        {
            if (elevator == null || elevatorEnt == null) return null;

            BasePlayer player = elevator.OwnerID != 0
                ? BasePlayer.FindByID(elevator.OwnerID)
                : null;

            if (player == null || !player.IsConnected) return null;

            if (config.RequirePermission && !permission.UserHasPermission(player.UserIDString, PermUse))
            {
                player.ChatMessage(Msg("NoPermission", player.UserIDString));
                return false;
            }

            if (config.CooldownSeconds > 0f)
            {
                float now = UnityEngine.Time.realtimeSinceStartup;
                float previous;
                if (lastCall.TryGetValue(player.userID, out previous))
                {
                    float remaining = config.CooldownSeconds - (now - previous);
                    if (remaining > 0f)
                    {
                        player.ChatMessage(Msg("Cooldown", player.UserIDString, Mathf.CeilToInt(remaining)));
                        return false;
                    }
                }
                lastCall[player.userID] = now;
            }

            return null;
        }

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

The plugin registers permission elevatorcallguard.use and checks it in OnElevatorCall. The caller's player is resolved from the elevator's owner entity chain (the elevator caller is owned by the player who built it); if that player is offline or lacks the permission, the hook returns false to block the car's move request and sends a chat message. When the permission check passes the hook returns null and normal elevator behavior continues. A config toggle lets admins disable the restriction entirely, and a short message explains the denial once per block.

Common use cases

  • Permission-gated elevators

    Block calls from players without a VIP or building permission so only trusted players can summon the car.

  • Cooldown between calls

    Track the last successful call per player and return non-null when the cooldown is still active to prevent spam.

  • Raid or event mode restrictions

    During your own event timers, disable elevator calls so attackers cannot use a defender's car to move loot or escape.

Pitfalls

  • Only fires for cars at the top

    The game callback only runs for cars where IsTop is true. Blocking here does not reposition a car that is elsewhere; it simply leaves the top car where it is.

  • Runs per car, not per player

    A single button press may evaluate several cars. Your permission check and chat message should be cheap and should not repeat the same message for every car.

  • Return value is only a veto

    The hook returns object but the game discards it. Returning true blocks just like returning false; return null to allow the move.

Build a plugin with OnElevatorCall

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

Prompt: Permission-gated elevators using the OnElevatorCall 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 OnElevatorCall

Generate