Skip to content
RustPluginGenerator

How to make a Rust hackable crate timer plugin (shorter VIP hack)

Overrides the hack duration of HackableLockedCrate entities and lets players with a VIP permission unlock them faster, using the OnCrateHack hook and a server-wide announcement when a hack begins.

Hackable locked crates on Oil Rigs, Cargo Ships and CH47 drops use a fixed hack time that rarely fits a custom server's pacing. Changing it means intercepting the crate when a player starts the hack and writing your own duration into hackSeconds. The catch is that you usually want two durations: a normal one for everyone and a faster one for donors. This plugin hooks OnCrateHack, resolves the owning player via BasePlayer.FindByID(crate.OwnerID), and replaces the crate's hackSeconds value with the base time from config or the VIP time when that player holds a permission. It also broadcasts a configurable chat announcement so the rest of the server knows a crate is being cracked. If no player is attached or the player lacks the permission, the base value applies. Everything is config-driven: both durations, whether the announcement fires, and whether it names the player.

The plugin code

HackableCrateTimer.cs
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Oxide.Core;

namespace Oxide.Plugins
{
    [Info("Hackable Crate Timer", "RustPluginGenerator", "1.0.0")]
    [Description("Overrides hackable locked crate hack time and gives VIP players a shorter duration.")]
    public class HackableCrateTimer : RustPlugin
    {
        private const string PermVip = "hackablecratetimer.vip";

        private PluginConfig config;

        private class PluginConfig
        {
            [JsonProperty("Normal hack seconds")]
            public float NormalHackSeconds = 900f;

            [JsonProperty("VIP hack seconds")]
            public float VipHackSeconds = 450f;

            [JsonProperty("Announce hack in chat")]
            public bool AnnounceHack = true;

            [JsonProperty("Include player name in announcement")]
            public bool AnnouncePlayerName = 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>
            {
                ["HackStarted"] = "<color=#e07b39>{0}</color> started hacking a locked crate!",
                ["HackStartedAnonymous"] = "A locked crate is being hacked somewhere on the map!"
            }, 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(PermVip, this);
        }

        private void OnCrateHack(HackableLockedCrate crate)
        {
            if (crate == null || crate.net == null || crate.IsDestroyed) return;

            float seconds = config.NormalHackSeconds;
            BasePlayer hacker = BasePlayer.FindByID(crate.OwnerID);

            if (hacker != null && !hacker.IsNpc && permission.UserHasPermission(hacker.UserIDString, PermVip))
            {
                seconds = config.VipHackSeconds;
            }

            // Overrides the vanilla duration the crate counts down from.
            crate.hackSeconds = seconds;

            if (!config.AnnounceHack) return;

            if (config.AnnouncePlayerName && hacker != null && !hacker.IsNpc)
            {
                Server.Broadcast(Msg("HackStarted", null, hacker.displayName));
            }
            else
            {
                Server.Broadcast(Msg("HackStartedAnonymous"));
            }
        }

        private void Unload()
        {
            config = null;
        }
    }
}

Hooks used: OnCrateHack

Config file

Created automatically on first load at oxide/config/HackableCrateTimer.json.

HackableCrateTimer.json
{
  "Normal hack seconds": 900,
  "VIP hack seconds": 450,
  "Announce hack in chat": true,
  "Include player name in announcement": true
}

Commands and permissions

No chat commands. The plugin works on its own.

Permissions
PermissionGrants
hackablecratetimer.vipGives the player the shorter VIP hack duration when they start hacking a locked crate.

How the code works

  1. Register the VIP permission

    Init registers hackablecratetimer.vip with permission.RegisterPermission(PermVip, this). The prefix matches the lowercase class name HackableCrateTimer, which is how Oxide expects permission strings to look. Grant it with oxide.grant user <steamid> hackablecratetimer.vip or to a group with oxide.group add vip followed by oxide.grant group vip hackablecratetimer.vip. Without the permission a player always gets the normal duration.

  2. Read both durations from config

    The nested PluginConfig class holds NormalHackSeconds, VipHackSeconds, AnnounceHack and AnnouncePlayerName, each with a [JsonProperty] name so the generated oxide/config/HackableCrateTimer.json is readable. LoadDefaultConfig fills the defaults, LoadConfig reads the file and falls back to defaults if parsing fails, and SaveConfig writes it back. Admins edit the JSON and reload the plugin; no recompile needed.

  3. Intercept the crate before its countdown runs

    OnCrateHack(HackableLockedCrate crate) fires when a player starts a hack. The plugin null-checks crate, crate.net and crate.IsDestroyed because the entity can be gone or dying. It then assigns crate.hackSeconds to the value it wants. Assigning hackSeconds here replaces the total duration the crate counts down from, so the number you write is the number of seconds the hack takes.

  4. Find out who started the hack

    The plugin resolves the hacker with BasePlayer.FindByID(crate.OwnerID) into a local BasePlayer hacker. It checks the reference is non-null, that hacker.IsNpc is false, and then calls permission.UserHasPermission(hacker.UserIDString, PermVip). That call is what selects VipHackSeconds over NormalHackSeconds. If the lookup returns null or the player is an NPC, the local seconds variable stays at NormalHackSeconds.

  5. Announce the hack in chat

    After setting crate.hackSeconds, the plugin returns early unless AnnounceHack is true. It builds the text from the HackStarted language key with hacker.displayName as the {0} argument passed to Msg, or from HackStartedAnonymous when AnnouncePlayerName is false or the hacker reference is not a real player. Server.Broadcast sends the resulting line to every connected player. Language strings live in LoadDefaultMessages and can be edited in oxide/lang/en/HackableCrateTimer.json.

  6. Keep the hook cheap

    OnCrateHack only fires when a player starts a hack, not on every tick, so a single Server.Broadcast and one permission lookup are fine. The plugin still avoids PrintWarning inside the hook and only logs a configuration problem at load time. The broadcast is gated behind AnnounceHack so servers that want the timer change without the noise can silence it entirely in the config file.

Install it on your server

  1. Save HackableCrateTimer.cs

    Keep the file name exactly as the class name. Oxide matches them.
  2. Upload it to the plugins folder

    Oxide: oxide/plugins/. Carbon: carbon/plugins/. The server compiles and loads it within a few seconds, no restart needed.
  3. Edit the config if you want

    On first load the default config is written to oxide/config/HackableCrateTimer.json (Carbon: carbon/configs/HackableCrateTimer.json). After editing, reload it:oxide.reload HackableCrateTimer c.reload HackableCrateTimer # Carbon
  4. Grant the permission

    Give it to every player, or swap default for a group such as vip:oxide.grant group default hackablecratetimer.vip c.grant group default hackablecratetimer.vip # Carbon

Variations

Each one opens the generator with a ready prompt you can tweak.

  • Per-location timing

    Give Oil Rig crates a different hack time than Cargo Ship or CH47 drops.

    Generate this version
  • Team-based VIP

    Treat a hacking player as VIP when any member of their team has the permission.

    Generate this version
  • Broadcast with map marker

    Drop a temporary map marker on the crate position when a hack starts.

    Generate this version

FAQ

Does setting `hackSeconds` in `OnCrateHack` actually override the vanilla timer?

OnCrateHack runs when a player starts a hack, and the plugin writes a new value into crate.hackSeconds, which the crate uses as the total duration for its countdown. Test after Rust patches in case the order of events changes.

What happens if a player without the VIP permission starts the hack?

The plugin falls back to NormalHackSeconds from your config. No permission error is shown, because the permission is optional and only affects the duration. Players without it still see the announcement when it is enabled and still get loot.

Can I disable the chat announcement?

Yes. Set Announce hack in chat to false in oxide/config/HackableCrateTimer.json and reload. The timer change still applies. If you want the announcement but not the player's name, keep it enabled and set Include player name in announcement to false.

Where do I install it and do I need Carbon?

Drop HackableCrateTimer.cs into oxide/plugins on an Oxide server, or the Carbon plugins folder on a Carbon server. Carbon loads the same file. Run oxide.reload HackableCrateTimer after editing the config, and grant the permission with oxide.grant user <steamid> hackablecratetimer.vip.

Customize it for your server

Change the reward, add a cooldown, restrict it to VIPs. Start from this prompt and edit anything.

Prompt: Rust Oxide plugin that overrides hackable locked crate hack time via OnCrateHack, with a normal duration and a shorter VIP duration for the hackablecratetimer.vip permission, plus a configurable chat announcement.
Customize for my server

Edit the prompt on the next screen. 2 free plugins a month, no card.

Last updated Oct 26, 2026.

Customize locked crate hack timer

Customize