RustTip

CanUseUI

OxideCarbonCUI

Called to determine whether to use ui.

Return true to allow the action and false to block it.

object CanUseUI(BasePlayer player, string json)

Parameters

player
BasePlayer
json
string

Return value

objectReturn non-null to cancel the game action.

Example

object — you can affect the game: return a value to change or cancel the action.

private object CanUseUI(BasePlayer player, string json)
{
    Puts("CanUseUI");

    // change nothing — the game continues as usual
    return null;

    // to affect the game:
    // return false; // non-null cancels the game action
}

Works in both Oxide and Carbon: Carbon loads Oxide plugins as is.

Where it is called

Oxide core (Oxide.Rust)
JsonWriterResources::AddUi(BasePlayer player, string json)

Oxide core code — the hook is called from here

public static bool AddUi(BasePlayer player, string json)
{
    if (player?.net != null && Interface.CallHook("CanUseUI", player, json) == null)
    {
        CommunityEntity.ServerInstance.ClientRPC(RpcTarget.Player("AddUI", player.net.connection), json);
        return true;
    }

    return false;
}

Injection point

Carbon
Oxide.Game.Rust.Cui.CuiHelper.AddUi
Inside CarbonCarbon.Common

Sources: Rust.opj from OxideMod/Oxide.Rust (MIT) and hook metadata of the Carbon documentation (MIT). Method code is decompiled from this branch's server.