Skip to content

EN API UO CancelGump

LIHACHTETAN edited this page Nov 28, 2026 · 3 revisions

Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어

UO.CancelGump

Home · C# · IDE · UO API · A–Z · Examples · Languages

C# signatures

void UO.CancelGump();
void UO.CancelGump(object? gumpId);

Closes the selected server gump via a compatible resolver CloseSimpleGump.

Parameters

  • gumpId — Optional int/numeric value. The resolver first looks for a matching server/local serial, then the server gump index. Without an argument, -1 is passed and the last gump is selected.

Return value

void - no return value.

Behavior

  • An argument named gumpId does not guarantee to search only ID. CloseGumpUnsafe for server gump sends button 0, then deletes the local window. If gump is not found, there is no action. This is not CancelMenu, nor is it clearing the pending WaitGump.

Standalone C# scripts

Each example can be saved as a separate file .csx and run in IDE. The UO object and wait functions provide the host of the current game session. Replace demo serial names, coordinates and addresses with your own.

Simple example

Run this code as a separate .csx file. Arguments appear directly in the call; replace demonstration names, serials and addresses with your own.

The command is a separate statement. The message before it marks the start of the call; it does not confirm a server action.

UO.Print("Calling UO.CancelGump");
UO.CancelGump();

1. Close last gump - direct script

Parameters and execution flow:

  • The form without an argument selects the latest available server gump.
UO.CancelGump();

2. Close gump by known ID - script function

Parameters and execution flow:

  • The actual ID of the first gump is used; the list may change between calls.
return  RunScenario();
 object? RunScenario()
{
    var id = UO.GetGumpID(0);
    if (Truth(id != 0))
    {
        UO.CancelGump(id);
    }

    return null;
}

bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;

3. Explicit last index - script class

Parameters and execution flow:

  • The value -1 explicitly selects the last gump in the resolver.
return  new ScriptScenario(UO, WaitAsync, Args, Cancellation, Checkpoint).RunScenario();
class ScriptScenario
{
    private readonly global::ClassicUO.CSharp.CSharpGameApi UO;
    private readonly Func<int, Task> WaitAsync;
    private readonly string[] Args;
    private readonly CancellationToken Cancellation;
    private readonly Action Checkpoint;
    public ScriptScenario(global::ClassicUO.CSharp.CSharpGameApi api, Func<int, Task> wait, string[] args, CancellationToken cancellation, Action checkpoint)
    {
        UO = api;
        WaitAsync = wait;
        Args = args;
        Cancellation = cancellation;
        Checkpoint = checkpoint;
    }

     public object? RunScenario()
    {
        UO.CancelGump(-1);
        return null;
    }
}

Command implementation

C# is case sensitive. Use the exact UO name. Compare numeric flags with 0; use bool only where the signature returns bool.

UO.CancelGump() — UO.CancelGump()

Parameters: No parameters.

Result: void / Unit.

During a call:

Internal implementation code; this is not a standalone script.

case "cancelgump": bridge.CloseSimpleGump(arguments.Length > 0 ? Arg(0) : -1); break;

UO.CancelGump(gumpId) — UO.CancelGump(Any)

Parameters: gumpId (Any)

Result: void / Unit.

During a call:

Internal implementation code; this is not a standalone script.

case "cancelgump": bridge.CloseSimpleGump(arguments.Length > 0 ? Arg(0) : -1); break;

Clone this wiki locally