Repository navigation
EN API UO OpenContainer
Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
Home · C# · IDE · UO API · A–Z · Examples · Languages
void UO.OpenContainer(object? id);
void UO.OpenContainer(object? id, object? timeout);Requests to open a container.
-
id— Serial/ID object: int, numeric/hex string or set alias, for example "lasttarget". This is not a graphic/type. Check the loaded object before taking action. -
timeout— Optional int, milliseconds; default is 0. A negative value does not add anticipation.
void - no value. Call on a separate line; completion does not confirm the server's action.
- Bridge.OpenContainer calls UseObject(id), then UO.Wait(timeout) only if timeout>0. The pause is fixed; the presence/contents of the container are not checked.
- Without timeout there is no pause. The end of the pause should not be taken as evidence that the content has opened or fully loaded.
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.
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.OpenContainer");
UO.OpenContainer("lasttarget");Parameters and execution flow:
- Requests to open a container.
UO.OpenContainer("lasttarget");Parameters and execution flow:
- Bridge.OpenContainer calls UseObject(id), then UO.Wait(timeout) only if timeout>0. The pause is fixed; the presence/contents of the container are not checked.
return RunScenario();
object? RunScenario()
{
if (Truth(UO.Exists("lasttarget")))
{
UO.OpenContainer("lasttarget", 1000);
}
return null;
}
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;Parameters and execution flow:
- Without timeout there is no pause. The end of the pause should not be taken as evidence that the content has opened or fully loaded.
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()
{
var id = UO.GetSerial("lasttarget");
if (Truth(UO.Exists(id)))
{
UO.OpenContainer(id, 1000);
UO.Print(UO.GetName(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;
}C# is case sensitive. Use the exact UO name. Compare numeric flags with 0; use bool only where the signature returns bool.
Parameters: id (Any)
Result: void / Unit.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.OpenContainer. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.OpenContainer:bridge.OpenContainer(GetObject(id), 0). -
InjectionScript.Runtime.InjectionApiUO.GetObject:GetObject(id).
Internal implementation code; this is not a standalone script.
public void OpenContainer(InjectionValue id) => bridge.OpenContainer(GetObject(id), 0);Parameters: id (Any), timeout (Any)
Result: void / Unit.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.OpenContainer. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.OpenContainer:bridge.OpenContainer(GetObject(id), NumberConversions.ToInt(timeout)). -
InjectionScript.Runtime.InjectionApiUO.GetObject:GetObject(id). -
InjectionScript.Runtime.NumberConversions.ToInt:NumberConversions.ToInt(timeout).
Internal implementation code; this is not a standalone script.
public void OpenContainer(InjectionValue id, InjectionValue timeout) => bridge.OpenContainer(GetObject(id), NumberConversions.ToInt(timeout));ClassicUO — Bad Newbie & C# Scripts IDE