Repository navigation
EN API UO Connect
Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
Home · C# · IDE · UO API · A–Z · Examples · Languages
void UO.Connect();Requests connection or reconnection of the current client session.
There are no parameters.
void - no return value.
- In a manager session, calls SessionControl.RequestConnect. In the standalone client, the active/prepared connection is left unchanged.
- For GameScene plans a saved reconnection so as not to change the scene during its Update. In LoginScene uses the current account and saved password, turns on Reconnect and calls Connect with the remembered shard/character even when automatic reconnect is turned off.
- The team is not waiting to enter the world. Check UO.Connected after a separate wait if further actions require a connection.
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.Connect");
UO.Connect();Parameters and execution flow:
- The call only initiates a connection.
UO.Connect();Parameters and execution flow:
- Verification can avoid re-request.
return RunScenario();
object? RunScenario()
{
if (!(Truth(UO.Connected())))
{
UO.Connect();
}
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:
- Waiting 1000 ms does not guarantee entry; the output shows the actual current flag.
return await new ScriptScenario(UO, WaitAsync, Args, Cancellation, Checkpoint).RunScenarioAsync();
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;
}
async public Task<object?> RunScenarioAsync()
{
UO.Connect();
await Delay(1000);
UO.Print(Convert.ToString(UO.Connected()));
return null;
}
Task Delay(object? milliseconds) => WaitAsync(checked((int)Convert.ToDouble(milliseconds)));
}C# is case sensitive. Use the exact UO name. Compare numeric flags with 0; use bool only where the signature returns bool.
Parameters: No parameters.
Result: void / Unit.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.ConnectClient:bridge.ConnectClient().
Internal implementation code; this is not a standalone script.
case "connect": bridge.ConnectClient(); return InjectionValue.Unit;ClassicUO — Bad Newbie & C# Scripts IDE