Skip to content
RustPluginGenerator

CanUseGesture

CanUseGesture is called when Oxide checks whether a player is allowed to use a gesture, from GestureConfig.IsOwnedBy. Returning a bool overrides the game's own ownership check.

Signature
object CanUseGesture(BasePlayer player, GestureConfig gestureConfig)

Parameters

Hook parameters
ParameterTypeDescription
playerBasePlayerThe BasePlayer who is trying to unlock or use a gesture. Check IsAdmin, permissions or team state here before allowing the gesture.
gestureConfigGestureConfigThe GestureConfig being checked. Not every field is documented, so treat it as an opaque object unless you have verified members on your build; it identifies which gesture is being evaluated.

Return value

Return true to let the player use the gesture or false to deny it; the game uses that bool as the result of GestureConfig.IsOwnedBy. Returning null (or anything other than a bool) leaves the original check in place, so the vanilla unlock rules apply.

How it works

This hook fires inside GestureConfig.IsOwnedBy(BasePlayer player, bool allowCinematic = false), which the game calls whenever it needs to know whether a given player may use a particular gesture. The gesture system uses that check for owned/unlocked emotes, so the hook fires each time the gesture is validated for a player rather than once at spawn. The first argument is the player being checked and the second is the gesture configuration itself.

Returning a bool replaces the result of the ownership check, so true allows the gesture and false denies it. Any other return value, or null, lets the original method continue and the vanilla unlock logic decides. Because the return is consumed by the game method, you cannot use this hook to grant a gesture permanently; it only changes the answer for this evaluation.

Declaring the player parameter as BasePlayer is the natural type here; narrowing it further is not useful since the game always passes a player. Keep the handler fast, since it runs on every validation and must not print or allocate heavily.

Example plugin: Restrict gestures to a permission group

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

namespace Oxide.Plugins
{
    [Info("GesturePermissionGate", "RustPluginGenerator", "1.0.0")]
    [Description("Restricts Rust gesture usage to players with a permission.")]
    public class GesturePermissionGate : RustPlugin
    {
        private const string PermUse = "gesturepermissiongate.use";

        private PluginConfig config;

        private class PluginConfig
        {
            [JsonProperty("Only players with permission can use gestures")]
            public bool RequirePermission { get; set; } = true;

            [JsonProperty("Admins bypass permission check")]
            public bool AdminsBypass { 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>
            {
                ["NoPermission"] = "You do not have permission to use gestures."
            }, 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 CanUseGesture(BasePlayer player, GestureConfig gestureConfig)
        {
            if (player == null || gestureConfig == null)
                return null;

            if (!config.RequirePermission)
                return null;

            if (player.IsNpc)
                return true;

            if (config.AdminsBypass && player.IsAdmin)
                return true;

            if (permission.UserHasPermission(player.UserIDString, PermUse))
                return true;

            player.ChatMessage(Msg("NoPermission", player.UserIDString));
            return false;
        }
    }
}

The plugin registers a single permission, gesturepermissiongate.use, that controls gesture access. When CanUseGesture runs, it rejects NPCs, lets admins through, and otherwise checks the permission: players with it get true, everyone else gets false. A config toggle lets admins disable the gate entirely so the server falls back to vanilla behaviour by returning null. Because the hook sits in the ownership check, the effect is applied per evaluation without touching player data, and no chat spam is produced. Revoking the permission with Oxide's oxide.grant/oxide.revoke takes effect on the next gesture validation.

Common use cases

  • VIP gesture access

    Gate all or some gestures behind a VIP permission so only paying players can use emotes. Toggle the whole gate from config when you want vanilla behaviour.

  • Block gestures during events

    Return false during a custom PvP event so players cannot spam emotes. Flip a flag in your event plugin and check it in the hook.

  • Team-only gestures

    Allow gestures only for players who are on a team, or deny them for wanted/cuffed players so emote usage reflects game state.

Pitfalls

  • Return value must be a bool

    Only a bool overrides the check. Returning a string, integer or other object leaves the original ownership result untouched, which can silently do nothing.

  • Deny is absolute

    Returning false denies the gesture even if the player legitimately owns it. Test with admin accounts and make sure you do not lock out players you did not intend to.

  • Fires often

    The check runs each time a gesture is validated. Keep the handler allocation-free and never call PrintWarning or other logging inside it.

Build a plugin with CanUseGesture

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

Prompt: VIP gesture access using the CanUseGesture 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 CanUseGesture

Generate