Repository navigation
EN UO Topic client connection
Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
Home · C# · IDE · UO API · A–Z · Examples · Languages
Connection, world entry status, latency, server address and character list.
| Topic | Commands and explanations |
|---|---|
| Connect | UO.Connect |
| Disconnect | UO.Disconnect |
| Connected | UO.Connected |
| Online | UO.Online |
| Ping | UO.GetPing |
| Server IP | UO.GameServerIPString |
| Shard Name | UO.ShardName |
| Shard Path | UO.ShardPath |
| Characters List | UO.GetCharsListForShard |
| Resend | UO.Resend |
| CheckLag | UO.CheckLag |
UO.Connect · UO.Disconnect · UO.Connected · UO.Online · UO.IsOnline · UO.ConnectedTime · UO.DisconnectedTime · UO.GetPing · UO.CheckLag · UO.GameServerIPString · UO.ShardName · UO.ShardPath · UO.GetCharsListForShard · UO.Resend · UO.CloseUO
Each command card has several independent scenarios: direct code, functions and classes. Below are selected short scenarios; restrictions and full analysis are in the cards.
Parameters, result and all scenarios
if (Truth(Truth(UO.Connected()) == false))
{
return null;
}
UO.UseSkill("Hiding");
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;Parameters, result and all scenarios
var address = UO.GameServerIPString();
UO.Print(address);Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
int UO.CheckLag();
dynamic UO.CheckLag(object? timeoutMS);
int UO.CheckLag(object? timeout, object? retries);Checks whether a fresh response from the game server has been received within the allotted time. Convenient before continuing the script after a network delay.
-
timeout— timeout / timeoutMS — waiting time for one attempt in milliseconds, converted to int. A negative value is limited to zero. With 0 the request can be sent, but there is no expectation of a response; It's not an infinite timeout. -
timeoutMS— timeout / timeoutMS — waiting time for one attempt in milliseconds, converted to int. A negative value is limited to zero. With 0 the request can be sent, but there is no expectation of a response; It's not an infinite timeout. -
retries- retries - TOTAL number of attempts, not the number of additional repetitions. Converts to int and is limited from below to one. For example, (250, 3) - up to three attempts at 250 ms; a successful response completes the check early.
Numeric flag int: 1 (condition met) - fresh response received; 0 (condition not met) - the request is impossible or the time limit has expired. Single parameter registration object? actually returns this int. This is not the ping value or the number of attempts.
- CheckLag() makes one attempt, waiting up to 10000 ms. CheckLag(timeoutMS) - one attempt with the specified expectation. CheckLag(timeout, retries) repeats the check until success or the total number of attempts is exhausted.
- Waiting delays the calling script rather than confirming the game action. The command does not reconnect and does not change network settings. The server may not respond to echo: failure in itself does not prove the connection has broken. The timing also depends on the flow scheduling; Don't call active checking on every frame. Stopping the script interrupts the wait.
- UO.GetPing · UO.CheckLag · UO.IsOnline
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 result of one call is printed in the journal. A number is not converted to bool; an array is displayed as its element count.
var result = UO.CheckLag();
UO.Print("CheckLag: " + Convert.ToString(result));Parameters and execution flow:
- A form without parameters can wait up to 10 seconds. true means a fresh echo response. Hiding is called by a separate command and can be overridden by game mechanics.
if (Truth(Truth(UO.CheckLag()) == true))
{
UO.UseSkill("Hiding");
}
else
{
UO.Print("No fresh server response");
}
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:
- 250 — waiting for one attempt, 3 — total attempts. If successful, no further attempts are made; with 0 the script does not continue. This is not a 250 ms ping measurement or three additional repeats.
return RunScenario();
object? RunScenario()
{
var responsive = UO.CheckLag(250, 3);
if (Truth(responsive == 0))
{
UO.Print("No response after the allowed attempts");
return null;
}
UO.Print("Fresh response received; the script can continue");
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:
- CanContinue(timeoutMs, attempts) first checks UO.IsOnline, then the latest answer. false and 0 are equivalent for this predicate. 500 ms and 2 attempts are specified separately; The function does not trigger automatic reconnection.
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()
{
if (!(Truth(CanContinue(500, 2))))
{
return null;
}
UO.UseSkill("Hiding");
return null;
}
dynamic CanContinue(dynamic timeoutMs, dynamic attempts)
{
if (Truth(Truth(UO.IsOnline()) == false))
{
return false;
}
return Truth(Truth(UO.CheckLag(timeoutMs, attempts)) == true);
}
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: No parameters.
Result: int / Integer.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.CheckLag. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.CheckLag:bridge.CheckLag(10_000).
Internal implementation code; this is not a standalone script.
public int CheckLag() => bridge.CheckLag(10_000);Parameters: timeoutMS (Any)
Result: dynamic / Any.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.CheckLag:bridge.CheckLag(Arg(0, 10_000)). -
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility::Arg:Arg(0, 10_000).
Internal implementation code; this is not a standalone script.
case "checklag": return new InjectionValue(bridge.CheckLag(Arg(0, 10_000)));Parameters: timeout (Any), retries (Any)
Result: int / Integer.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.CheckLag. -
InjectionScript.Runtime.NumberConversions.ToInt:NumberConversions.ToInt(timeout). -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.CheckLag:bridge.CheckLag(timeoutMs).
Internal implementation code; this is not a standalone script.
public int CheckLag(InjectionValue timeout, InjectionValue retries)
{
int timeoutMs = Math.Max(0, NumberConversions.ToInt(timeout));
int attempts = Math.Max(1, NumberConversions.ToInt(retries));
for (int attempt = 0; attempt < attempts; attempt++)
{
if (bridge.CheckLag(timeoutMs) != 0)
return 1;
}
return 0;
}Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
void UO.CloseUO();Requests the current client application to exit via Client.Game.Exit.
There are no parameters.
void - no return value.
- CloseUO is sent to the same bridge.CloseHandle. Exit is executed on the game thread; if Client.Game is missing, there is no action. The command is not a shutdown of a separate gump.
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.CloseUO");
UO.CloseUO();Parameters and execution flow:
- The call requests termination of the client application.
UO.CloseUO();Parameters and execution flow:
- The example shows a controlled condition; the value 0 keeps the client open.
return RunScenario();
object? RunScenario()
{
var finishClient = 0;
if (Truth(finishClient))
{
UO.CloseUO();
}
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:
- A fully declared helper allows for explicit exit enablement.
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()
{
FinishClient(0);
return null;
}
void FinishClient(dynamic enabled)
{
if (Truth(enabled))
{
UO.CloseUO();
}
}
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: No parameters.
Result: void / Unit.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.ExecuteLegacyManualAlias. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.CloseHandle:bridge.CloseHandle().
Internal implementation code; this is not a standalone script.
case "closeuo": bridge.CloseHandle(); break;Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
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;Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
dynamic UO.Connected();Checks if the current session is in the game world and if its game connection is open. Use before a character action or while waiting for entry.
There are no parameters.
int. 1 - there is a player, a loaded card and an active game socket at the same time; otherwise 0. An open client window, a list of characters, or a TCP connection at the login stage does not mean 1. Numeric flag int: 1 (condition met), 0 (condition not met). This is a numeric flag: in C# check result != 0 or result == 0. Direct comparison of int with true/false and if (result) is not allowed.
The result of the command is a numeric flag: 1 means a fulfilled condition, 0 means an unfulfilled one. After var result = command(...) check if (result != 0) or if (result == 0). Save the result of one call: a repeated call can perform the action again or read the state that has already changed.
- There are no parameters: serial, type, character name and IP cannot be passed. UO.Online(), UO.Connected() and UO.IsOnline() check the same thing. This is the state of the given session owner, not another manager profile.
- The command only reads the local state. It does not send a ping, does not connect, does not pause, and does not check the availability of the Internet. After reading, the connection may change; 1 does not guarantee the success of the next action.
- UO.Wait takes milliseconds. Autopause when the connection is lost and manual pause delay the execution of examples: the timeout check will continue only after the pause is removed. These commands do not unpause themselves and do not enable auto-reconnect.
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 result of one call is printed in the journal. A number is not converted to bool; an array is displayed as its element count.
object? result = UO.Connected();
UO.Print(result is Array values ? "Count: " + values.Length : Convert.ToString(result));Parameters and execution flow:
- false is equivalent to 0. return terminates Main to UseSkill. Hiding is the only parameter of UseSkill, the name of the skill. With 1 the script only asks to use the skill; the result depends on the state of the character and the server.
- The command only reads the local state. It does not send a ping, does not connect, does not pause, and does not check the availability of the Internet. After reading, the connection may change; 1 does not guarantee the success of the next action.
if (Truth(Truth(UO.Connected()) == false))
{
return null;
}
UO.UseSkill("Hiding");
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:
- Comparison with 0 checks the current connection, not the auto-reconnect setting. Connect without arguments uses the saved settings and does not wait for the login to complete. Repeating a command during a login that has already started should not create a second session.
- The command only reads the local state. It does not send a ping, does not connect, does not pause, and does not check the availability of the Internet. After reading, the connection may change; 1 does not guarantee the success of the next action.
return RunScenario();
object? RunScenario()
{
if (Truth(UO.Connected() == 0))
{
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:
- WaitForWorld(timeoutMs) is a fully shown user-defined function, not a built-in command. 5000 — budget in ms, UO.Wait(50) — check interval. A negative value gives false; 0 only allows a ready-made world. Timer measures seconds, so the difference is multiplied by 1000. Autopause must be turned off in advance, otherwise Main exits. The function does not call Connect and does not cancel the started input when the time expires.
- The command only reads the local state. It does not send a ping, does not connect, does not pause, and does not check the availability of the Internet. After reading, the connection may change; 1 does not guarantee the success of the next action.
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()
{
if (Truth(UO.GetPauseScriptOnDisconnectStatus()))
{
return null;
}
if (Truth(await WaitForWorld(5000)))
{
UO.UseSkill("Hiding");
}
return null;
}
async Task<dynamic> WaitForWorld(dynamic timeoutMs)
{
if (Truth(timeoutMs < 0))
{
return false;
}
var started = Environment.TickCount;
while (!(Truth(UO.Connected())))
{
if (Truth((Environment.TickCount - started) * 1000.0 >= timeoutMs))
{
return false;
}
await Delay(50);
}
return true;
}
Task Delay(object? milliseconds) => WaitAsync(checked((int)Convert.ToDouble(milliseconds)));
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: No parameters.
Result: dynamic / Any.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.IsOnline:bridge.IsOnline().
Internal implementation code; this is not a standalone script.
case "connected": return new InjectionValue(bridge.IsOnline());Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
dynamic UO.ConnectedTime();Returns the calendar stamp of the character's last successful entry into the world. Helps you understand if the connection has changed while waiting or pausing before continuing the same task.
There are no parameters.
double: number of days from 1899-12-30, fractional part - time of day (OLE Automation date). 0 means that this session owner has not yet entered the world. After disconnection, the last input mark is retained. This is not a bool or a duration in seconds.
- There are no arguments. The history is common for scripts of the same session owner: late start, pause and close IDE do not change the marks. A new session process begins a new story; it is not a log of all connections.
- A failed login attempt without the character appearing in the world is not considered a successful login. Repeated offline checks do not change the shutdown time. For the current state, use UO.Connected() rather than a non-zero date.
- The clocks are taken from the computer's local clock. The difference multiplied by 86400 gives calendar seconds; Changing the clock/time zone may skew the results. For timeouts, use monotonic Timer(). Individual calls do not form an atomic snapshot; the same mark is not a unique ID connection.
- UO.Wait takes milliseconds. Autopause when the connection is lost and manual pause delay the execution of examples: the timeout check will continue only after the pause is removed. These commands do not unpause themselves and do not enable auto-reconnect.
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 result of one call is printed in the journal. A number is not converted to bool; an array is displayed as its element count.
object? result = UO.ConnectedTime();
UO.Print(result is Array values ? "Count: " + values.Length : Convert.ToString(result));Parameters and execution flow:
- 0 checks for the absence of inputs in this particular process. Connect uses the saved profile and only asks for login. This example intentionally does not restore an already terminated connection.
- UO.Wait takes milliseconds. Autopause when the connection is lost and manual pause delay the execution of examples: the timeout check will continue only after the pause is removed. These commands do not unpause themselves and do not enable auto-reconnect.
if (Truth(UO.ConnectedTime() == 0))
{
UO.Connect();
}
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:
- 30.0 — monitoring budget in Timer seconds; 250 — interval UO.Wait in ms. After changing the entry mark, CancelWaitTarget clears the previous deferred target. If there is no new input, the loop ends without this action.
- UO.Wait takes milliseconds. Autopause when the connection is lost and manual pause delay the execution of examples: the timeout check will continue only after the pause is removed. These commands do not unpause themselves and do not enable auto-reconnect.
return await RunScenarioAsync();
async Task<object?> RunScenarioAsync()
{
var login = UO.ConnectedTime();
var started = Environment.TickCount;
while (Truth(Environment.TickCount - started < 30.0))
{
if (Truth(UO.Connected()) && Truth(UO.ConnectedTime() != login))
{
UO.CancelWaitTarget();
return null;
}
await Delay(250);
}
return null;
}
Task Delay(object? milliseconds) => WaitAsync(checked((int)Convert.ToDouble(milliseconds)));
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:
- SameConnection(login) returns bool. We save the mark, wait for 500 ms, then disable continuation if there is no connection or the input changes. This is a re-test and not a guarantee of future server availability.
- UO.Wait takes milliseconds. Autopause when the connection is lost and manual pause delay the execution of examples: the timeout check will continue only after the pause is removed. These commands do not unpause themselves and do not enable auto-reconnect.
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()
{
var login = UO.ConnectedTime();
await Delay(500);
if (!(Truth(SameConnection(login))))
{
return null;
}
UO.AddToSystemJournal("Same connection; continue this batch");
return null;
}
dynamic SameConnection(dynamic login)
{
return Truth(login != 0) && Truth(UO.Connected()) && Truth(UO.ConnectedTime() == login);
}
Task Delay(object? milliseconds) => WaitAsync(checked((int)Convert.ToDouble(milliseconds)));
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: No parameters.
Result: dynamic / Any.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility. -
InjectionScript.Runtime.InjectionApiUO.UpdateConnectionState:UpdateConnectionState().
Internal implementation code; this is not a standalone script.
case "connectedtime":
UpdateConnectionState();
return new InjectionValue(state.ConnectedTime == default(DateTime) ? 0d : state.ConnectedTime.ToOADate());Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
void UO.Disconnect();Disconnects the current or installed client transport and prepares scripts for reconnection.
There are no parameters.
void - no return value.
- If automatic reconnect is turned off, BeginScriptControlledDisconnect saves the worker making the call for later UO.Connect. The manager session receives RequestDisconnect.
- The standalone client calls Socket.Disconnect and PrepareForReconnect. When global reconnect is enabled, it explicitly schedules the saved scene transition. In LoginScene clears the popup and returns Main.
- Returning void does not report the result of the reconnection. The connection status is read separately; Auto reconnect settings can initiate a new login.
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.Disconnect");
UO.Disconnect();Parameters and execution flow:
- The command cancels both the active and the installed transport.
UO.Disconnect();Parameters and execution flow:
- With AR turned off, the calling worker can reach Connect himself.
return await RunScenarioAsync();
async Task<object?> RunScenarioAsync()
{
UO.Disconnect();
await Delay(1000);
UO.Connect();
return null;
}
Task Delay(object? milliseconds) => WaitAsync(checked((int)Convert.ToDouble(milliseconds)));Parameters and execution flow:
- The condition uses a local flag for the current session.
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()
{
if (Truth(UO.Connected()))
{
UO.Disconnect();
}
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: No parameters.
Result: void / Unit.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.DisconnectClient:bridge.DisconnectClient().
Internal implementation code; this is not a standalone script.
case "disconnect": bridge.DisconnectClient(); return InjectionValue.Unit;Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
dynamic UO.DisconnectedTime();Returns the calendar stamp of the last time the game connection was lost. It is needed to diagnose a break and estimate the duration of a completed connection, and not to determine the number of login attempts.
There are no parameters.
double: number of days from 1899-12-30 with fractional part of the day. After the break - the time when the client noticed the outage; before the first break is the time when the session owner was created. This is not an offline flag and not milliseconds.
- There are no arguments. The history is common for scripts of the same session owner: late start, pause and close IDE do not change the marks. A new session process begins a new story; it is not a log of all connections.
- A failed login attempt without the character appearing in the world is not considered a successful login. Repeated offline checks do not change the shutdown time. For the current state, use UO.Connected() rather than a non-zero date.
- The clocks are taken from the computer's local clock. The difference multiplied by 86400 gives calendar seconds; Changing the clock/time zone may skew the results. For timeouts, use monotonic Timer(). Individual calls do not form an atomic snapshot; the same mark is not a unique ID connection.
- UO.Wait takes milliseconds. Autopause when the connection is lost and manual pause delay the execution of examples: the timeout check will continue only after the pause is removed. These commands do not unpause themselves and do not enable auto-reconnect.
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 result of one call is printed in the journal. A number is not converted to bool; an array is displayed as its element count.
object? result = UO.DisconnectedTime();
UO.Print(result is Array values ? "Count: " + values.Length : Convert.ToString(result));Parameters and execution flow:
- CompletedConnectionSeconds() returns seconds or -1 if there is no completed connection or the input has changed between reads. 86400 — seconds in a day. Only the last input/break pair is recalculated; The function does not summarize the history of all sessions.
- UO.Wait takes milliseconds. Autopause when the connection is lost and manual pause delay the execution of examples: the timeout check will continue only after the pause is removed. These commands do not unpause themselves and do not enable auto-reconnect.
var seconds = CompletedConnectionSeconds();
if (Truth(seconds >= 0))
{
UO.AddToSystemJournal("Completed connection seconds: " + Convert.ToString(seconds));
}
dynamic CompletedConnectionSeconds()
{
var login = UO.ConnectedTime();
var loss = UO.DisconnectedTime();
if (Truth(login == 0) || Truth(loss < login) || Truth(UO.Connected()))
{
return -1;
}
if (Truth(UO.ConnectedTime() != login))
{
return -1;
}
return (loss - login) * 86400.0;
}
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:
- When autopause is enabled, this controller exits immediately; To work offline it must be turned off in advance. After UO.Wait(1000) offline and the previous break mark are checked again. Connect does not guarantee success and does not replace the auto-reconnect setting.
- UO.Wait takes milliseconds. Autopause when the connection is lost and manual pause delay the execution of examples: the timeout check will continue only after the pause is removed. These commands do not unpause themselves and do not enable auto-reconnect.
return await RunScenarioAsync();
async Task<object?> RunScenarioAsync()
{
if (Truth(UO.GetPauseScriptOnDisconnectStatus()))
{
return null;
}
if (Truth(UO.Connected()))
{
return null;
}
var loss = UO.DisconnectedTime();
await Delay(1000);
if (!(Truth(UO.Connected())) && Truth(UO.DisconnectedTime() == loss))
{
UO.Connect();
}
return null;
}
Task Delay(object? milliseconds) => WaitAsync(checked((int)Convert.ToDouble(milliseconds)));
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:
- Comparison with previousLoss notices a break even after re-entry has already taken place. 30 seconds limit monitoring while the script is running, WaitAsync(250) frees the thread between checks. Multiple interruptions can be combined into one notification.
- UO.Wait takes milliseconds. Autopause when the connection is lost and manual pause delay the execution of examples: the timeout check will continue only after the pause is removed. These commands do not unpause themselves and do not enable auto-reconnect.
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()
{
var previousLoss = UO.DisconnectedTime();
var started = Environment.TickCount;
while (Truth(Environment.TickCount - started < 30.0))
{
if (Truth(UO.DisconnectedTime() != previousLoss))
{
UO.AddToSystemJournal("A connection loss occurred; check the session");
return null;
}
await Delay(250);
}
return null;
}
Task Delay(object? milliseconds) => WaitAsync(checked((int)Convert.ToDouble(milliseconds)));
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: No parameters.
Result: dynamic / Any.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility. -
InjectionScript.Runtime.InjectionApiUO.UpdateConnectionState:UpdateConnectionState().
Internal implementation code; this is not a standalone script.
case "disconnectedtime":
UpdateConnectionState();
return new InjectionValue(state.DisconnectedTime.ToOADate());Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
dynamic UO.GameServerIPString();Reads the configured server address from the client's global settings.
There are no parameters.
string — Settings.GlobalSettings.IP or an empty string if there is no value.
- GameServerAddress in the current bridge reads the global setting IP. This is not a DNS/network request, nor is it checking the actual peer's address; a manager session can have its own connection parameters.
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 result of one call is printed in the journal. A number is not converted to bool; an array is displayed as its element count.
object? result = UO.GameServerIPString();
UO.Print(result is Array values ? "Count: " + values.Length : Convert.ToString(result));Parameters and execution flow:
- The current global setting IP is returned.
var address = UO.GameServerIPString();
UO.Print(address);Parameters and execution flow:
- A blank value indicates no configuration and not a measured network failure.
return RunScenario();
object? RunScenario()
{
var address = UO.GameServerIPString();
if (Truth(Len(address) == 0))
{
UO.Print("no configured address");
}
return null;
}
int Len(object? value) => Convert.ToString(value)?.Length ?? 0;
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:
- The variable stores the string obtained by the first call.
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()
{
var address = UO.GameServerIPString();
await Delay(100);
UO.Print(address);
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: dynamic / Any.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.GameServerAddress:bridge.GameServerAddress.
Internal implementation code; this is not a standalone script.
case "gameserveripstring": return new InjectionValue(bridge.GameServerAddress);Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
dynamic UO.GetCharsListForShard();Returns the character names of the current shard known to the client.
There are no parameters.
Array of strings. There are no known names and the current character is an empty array.
- The manager session reads SessionControl.Characters. In standalone, LastCharacterManager is used first for account/server; if the list is empty, read LoginScene.Characters without empty names; then the current Player.Name is used as the only element.
- These are locally famous names; the command does not request a complete list from the server and does not guarantee the freshness of the cache.
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 result of one call is printed in the journal. A number is not converted to bool; an array is displayed as its element count.
object? result = UO.GetCharsListForShard();
UO.Print(result is Array values ? "Count: " + values.Length : Convert.ToString(result));Parameters and execution flow:
- The loop operates on an actual array of known names.
var names = UO.GetCharsListForShard();
for (int i = (int)(0); i <= ArrayLength(names)-1; i += (int)(1))
{
UO.Print(names[i]);
}
int ArrayLength(object? value) => value is System.Array array ? array.Length : 0;Parameters and execution flow:
- The index 0 is only used for a non-empty array.
return RunScenario();
object? RunScenario()
{
var names = UO.GetCharsListForShard();
if (Truth(ArrayLength(names) > 0))
{
UO.Print(names[0]);
}
return null;
}
int ArrayLength(object? value) => value is System.Array array ? array.Length : 0;
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:
- The list size does not indicate the number of account slots on the server.
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 names = UO.GetCharsListForShard();
UO.Print(Convert.ToString(ArrayLength(names)));
return null;
}
int ArrayLength(object? value) => value is System.Array array ? array.Length : 0;
}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: dynamic / Any.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility. -
InjectionScript.Runtime.InjectionApiUO.StringArray:StringArray(bridge.GetCharactersForCurrentShard()). -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.GetCharactersForCurrentShard:bridge.GetCharactersForCurrentShard().
Internal implementation code; this is not a standalone script.
case "getcharslistforshard": return StringArray(bridge.GetCharactersForCurrentShard());Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
int UO.GetPing();
int UO.GetPing(object? timeout);Reads the game server response delay. Without argument, uses the last dimension; with a timeout requests a fresh response.
-
timeout— timeout / timeoutMS — waiting time for one attempt in milliseconds, converted to int. A negative value is limited to zero. With 0 the request can be sent, but there is no expectation of a response; It's not an infinite timeout.
int, milliseconds. Value >= 0 – measurement; 0 ms are also acceptable. -1 - no measurement: for a form with an argument, the request was not completed or the response was not received on time. This is NOT bool; 0 cannot be considered a failure and -1 a success.
- GetPing() does not send anything and immediately reads the last ServerPing. The old value by itself does not prove that the connection is now working. This is the last server echo measurement, not the smoothed/backup TCP indicator ping and not the ICMP Ping(host). GetPing(timeout) waits for a new response and then reads the last server measurement.
- Waiting delays the calling script rather than confirming the game action. The command does not reconnect and does not change network settings. The server may not respond to echo: failure in itself does not prove the connection has broken. The timing also depends on the flow scheduling; Don't call active checking on every frame. Stopping the script interrupts the wait.
- UO.GetPing · UO.CheckLag · UO.IsOnline
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 result of one call is printed in the journal. A number is not converted to bool; an array is displayed as its element count.
var result = UO.GetPing();
UO.Print("GetPing: " + Convert.ToString(result));Parameters and execution flow:
- Read cache without new network request. The example selects 50 or 200 ms to wait for the script itself at a threshold of 250 ms. The unknown dimension is processed separately. These numbers are an example setting, not a universal server limit.
var pingMs = UO.GetPing();
if (Truth(pingMs < 0))
{
UO.Print("No server latency sample");
return null;
}
var delayMs = 50;
if (Truth(pingMs > 250))
{
delayMs = 200;
}
await Delay(delayMs);
Task Delay(object? milliseconds) => WaitAsync(checked((int)Convert.ToDouble(milliseconds)));
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:
- 1000 — maximum wait for a fresh response in milliseconds. At -1 the procedure ends. If the measurement is successful, Hiding is requested; an echo response does not prove successful use of the skill.
return RunScenario();
object? RunScenario()
{
var pingMs = UO.GetPing(1000);
if (Truth(pingMs == -1))
{
UO.Print("No fresh server response");
return null;
}
UO.UseSkill("Hiding");
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:
- MeanPing(samples, timeoutMs) shown in full: 3 attempts at 500 ms; unsuccessful measurements are excluded from the average. If there are no successful ones, -1 is returned. samples limited to 1–10; UO.Wait(100) reduces the request rate between attempts.
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()
{
var meanMs = await MeanPing(3, 500);
if (Truth(meanMs < 0))
{
UO.Print("No successful samples");
}
else
{
UO.Print("Measured mean, ms: " + Convert.ToString(meanMs));
}
return null;
}
async Task<dynamic> MeanPing(dynamic samples, dynamic timeoutMs)
{
if (Truth(samples < 1) || Truth(samples > 10))
{
return -1;
}
var total = 0;
var count = 0;
for (int i = (int)(1); i <= samples; i += (int)(1))
{
var current = UO.GetPing(timeoutMs);
if (Truth(current >= 0))
{
total = total + current;
count = count + 1;
}
await Delay(100);
}
if (Truth(count == 0))
{
return -1;
}
return total / count;
}
Task Delay(object? milliseconds) => WaitAsync(checked((int)Convert.ToDouble(milliseconds)));
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: No parameters.
Result: int / Integer.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.GetPing. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.GetPing:bridge.GetPing().
Internal implementation code; this is not a standalone script.
public int GetPing() => bridge.GetPing();Parameters: timeout (Any)
Result: int / Integer.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.GetPing. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.GetPing:bridge.GetPing(Math.Max(0, NumberConversions.ToInt(timeout))). -
InjectionScript.Runtime.NumberConversions.ToInt:NumberConversions.ToInt(timeout).
Internal implementation code; this is not a standalone script.
public int GetPing(InjectionValue timeout) => bridge.GetPing(Math.Max(0, NumberConversions.ToInt(timeout)));Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
int UO.IsOnline();Checks if the current session is in the game world and if its game connection is open. Use before a character action or while waiting for entry.
There are no parameters.
int. 1 - there is a player, a loaded card and an active game socket at the same time; otherwise 0. An open client window, a list of characters, or a TCP connection at the login stage does not mean 1. Numeric flag int: 1 (condition met), 0 (condition not met). This is a numeric flag: in C# check result != 0 or result == 0. Direct comparison of int with true/false and if (result) is not allowed.
The result of the command is a numeric flag: 1 means a fulfilled condition, 0 means an unfulfilled one. After var result = command(...) check if (result != 0) or if (result == 0). Save the result of one call: a repeated call can perform the action again or read the state that has already changed.
- There are no parameters: serial, type, character name and IP cannot be passed. UO.Online(), UO.Connected() and UO.IsOnline() check the same thing. This is the state of the given session owner, not another manager profile.
- The command only reads the local state. It does not send a ping, does not connect, does not pause, and does not check the availability of the Internet. After reading, the connection may change; 1 does not guarantee the success of the next action.
- UO.Wait takes milliseconds. Autopause when the connection is lost and manual pause delay the execution of examples: the timeout check will continue only after the pause is removed. These commands do not unpause themselves and do not enable auto-reconnect.
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 result of one call is printed in the journal. A number is not converted to bool; an array is displayed as its element count.
var result = UO.IsOnline();
UO.Print("IsOnline: " + Convert.ToString(result));Parameters and execution flow:
- false is equivalent to 0. return terminates Main to UseSkill. Hiding is the only parameter of UseSkill, the name of the skill. With 1 the script only asks to use the skill; the result depends on the state of the character and the server.
- The command only reads the local state. It does not send a ping, does not connect, does not pause, and does not check the availability of the Internet. After reading, the connection may change; 1 does not guarantee the success of the next action.
if (Truth(Truth(UO.IsOnline()) == false))
{
return null;
}
UO.UseSkill("Hiding");
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:
- Comparison with 0 checks the current connection, not the auto-reconnect setting. Connect without arguments uses the saved settings and does not wait for the login to complete. Repeating a command during a login that has already started should not create a second session.
- The command only reads the local state. It does not send a ping, does not connect, does not pause, and does not check the availability of the Internet. After reading, the connection may change; 1 does not guarantee the success of the next action.
return RunScenario();
object? RunScenario()
{
if (Truth(UO.IsOnline() == 0))
{
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:
- WaitForWorld(timeoutMs) is a fully shown user-defined function, not a built-in command. 5000 — budget in ms, UO.Wait(50) — check interval. A negative value gives false; 0 only allows a ready-made world. Timer measures seconds, so the difference is multiplied by 1000. Autopause must be turned off in advance, otherwise Main exits. The function does not call Connect and does not cancel the started input when the time expires.
- The command only reads the local state. It does not send a ping, does not connect, does not pause, and does not check the availability of the Internet. After reading, the connection may change; 1 does not guarantee the success of the next action.
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()
{
if (Truth(UO.GetPauseScriptOnDisconnectStatus()))
{
return null;
}
if (Truth(await WaitForWorld(5000)))
{
UO.UseSkill("Hiding");
}
return null;
}
async Task<dynamic> WaitForWorld(dynamic timeoutMs)
{
if (Truth(timeoutMs < 0))
{
return false;
}
var started = Environment.TickCount;
while (!(Truth(UO.IsOnline())))
{
if (Truth((Environment.TickCount - started) * 1000.0 >= timeoutMs))
{
return false;
}
await Delay(50);
}
return true;
}
Task Delay(object? milliseconds) => WaitAsync(checked((int)Convert.ToDouble(milliseconds)));
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: No parameters.
Result: int / Integer.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.IsOnline. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.IsOnline:bridge.IsOnline().
Internal implementation code; this is not a standalone script.
public int IsOnline() => bridge.IsOnline();Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
int UO.Online();Checks if the current session is in the game world and if its game connection is open. Use before a character action or while waiting for entry.
There are no parameters.
int. 1 - there is a player, a loaded card and an active game socket at the same time; otherwise 0. An open client window, a list of characters, or a TCP connection at the login stage does not mean 1. Numeric flag int: 1 (condition met), 0 (condition not met). This is a numeric flag: in C# check result != 0 or result == 0. Direct comparison of int with true/false and if (result) is not allowed.
The result of the command is a numeric flag: 1 means a fulfilled condition, 0 means an unfulfilled one. After var result = command(...) check if (result != 0) or if (result == 0). Save the result of one call: a repeated call can perform the action again or read the state that has already changed.
- There are no parameters: serial, type, character name and IP cannot be passed. UO.Online(), UO.Connected() and UO.IsOnline() check the same thing. This is the state of the given session owner, not another manager profile.
- The command only reads the local state. It does not send a ping, does not connect, does not pause, and does not check the availability of the Internet. After reading, the connection may change; 1 does not guarantee the success of the next action.
- UO.Wait takes milliseconds. Autopause when the connection is lost and manual pause delay the execution of examples: the timeout check will continue only after the pause is removed. These commands do not unpause themselves and do not enable auto-reconnect.
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 result of one call is printed in the journal. A number is not converted to bool; an array is displayed as its element count.
var result = UO.Online();
UO.Print("Online: " + Convert.ToString(result));Parameters and execution flow:
- false is equivalent to 0. return terminates Main to UseSkill. Hiding is the only parameter of UseSkill, the name of the skill. With 1 the script only asks to use the skill; the result depends on the state of the character and the server.
- The command only reads the local state. It does not send a ping, does not connect, does not pause, and does not check the availability of the Internet. After reading, the connection may change; 1 does not guarantee the success of the next action.
if (Truth(Truth(UO.Online()) == false))
{
return null;
}
UO.UseSkill("Hiding");
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:
- Comparison with 0 checks the current connection, not the auto-reconnect setting. Connect without arguments uses the saved settings and does not wait for the login to complete. Repeating a command during a login that has already started should not create a second session.
- The command only reads the local state. It does not send a ping, does not connect, does not pause, and does not check the availability of the Internet. After reading, the connection may change; 1 does not guarantee the success of the next action.
return RunScenario();
object? RunScenario()
{
if (Truth(UO.Online() == 0))
{
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:
- WaitForWorld(timeoutMs) is a fully shown user-defined function, not a built-in command. 5000 — budget in ms, UO.Wait(50) — check interval. A negative value gives false; 0 only allows a ready-made world. Timer measures seconds, so the difference is multiplied by 1000. Autopause must be turned off in advance, otherwise Main exits. The function does not call Connect and does not cancel the started input when the time expires.
- The command only reads the local state. It does not send a ping, does not connect, does not pause, and does not check the availability of the Internet. After reading, the connection may change; 1 does not guarantee the success of the next action.
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()
{
if (Truth(UO.GetPauseScriptOnDisconnectStatus()))
{
return null;
}
if (Truth(await WaitForWorld(5000)))
{
UO.UseSkill("Hiding");
}
return null;
}
async Task<dynamic> WaitForWorld(dynamic timeoutMs)
{
if (Truth(timeoutMs < 0))
{
return false;
}
var started = Environment.TickCount;
while (!(Truth(UO.Online())))
{
if (Truth((Environment.TickCount - started) * 1000.0 >= timeoutMs))
{
return false;
}
await Delay(50);
}
return true;
}
Task Delay(object? milliseconds) => WaitAsync(checked((int)Convert.ToDouble(milliseconds)));
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: No parameters.
Result: int / Integer.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.RegisterCharacterGetterAliases [Online]. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.IsOnline:bridge.IsOnline().
The call executes the stored handler delegate. The registration method creates this delegate while building the API.
Internal implementation code; this is not a standalone script.
() => bridge.IsOnline()API creation: These functions register the API. They do not run again for every command call.
Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
void UO.Resend();Sends a request to resync the world.
There are no parameters.
void - no value. Call on a separate line; completion does not confirm the server's action.
- Resync sends NetClient.Socket.Send_Resync on the game thread. This is an update request, not a reconnection, or an acknowledgment that data has been received.
- In the examples, UO.Wait specifies only a script pause; the end of the pause does not prove that the server has completed the request.
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.Resend");
UO.Resend();Parameters and execution flow:
- Sends a request to resync the world.
UO.Resend();Parameters and execution flow:
- Resync sends NetClient.Socket.Send_Resync on the game thread. This is an update request, not a reconnection, or an acknowledgment that data has been received.
return RunScenario();
object? RunScenario()
{
if (Truth(UO.IsOnline()))
{
UO.Resend();
}
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:
- In the examples, UO.Wait specifies only a script pause; the end of the pause does not prove that the server has completed the request.
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.Resend();
UO.Wait(500);
UO.Print(UO.GetX());
return null;
}
}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.ExecuteLegacyManualAlias. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.Resync:bridge.Resync().
Internal implementation code; this is not a standalone script.
case "resend": bridge.Resync(); break;Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
dynamic UO.ShardName();Reads the shard name.
There are no parameters.
string — text of the bridge field.ShardName; without available data, an empty string is possible. This is not a connection sign and is not a numeric ID.
- ExecuteClientApiCompatibility returns bridge.ShardName without changing the profile or server selection.
- Reads the current local state. There is no package, target or automatic update; individual reads may see different states.
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 result of one call is printed in the journal. A number is not converted to bool; an array is displayed as its element count.
object? result = UO.ShardName();
UO.Print(result is Array values ? "Count: " + values.Length : Convert.ToString(result));Parameters and execution flow:
- Reads the shard name.
var value = UO.ShardName();
UO.Print(value);Parameters and execution flow:
- ExecuteClientApiCompatibility returns bridge.ShardName without changing the profile or server selection.
return RunScenario();
object? RunScenario()
{
var value = UO.ShardName();
if (Truth(Len(value) > 0))
{
UO.TextPrint(value);
}
return null;
}
int Len(object? value) => Convert.ToString(value)?.Length ?? 0;
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:
- Reads the current local state. There is no package, target or automatic update; individual reads may see different states.
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 before = UO.ShardName();
UO.Wait(500);
var after = UO.ShardName();
UO.Print(before = after);
return null;
}
}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: dynamic / Any.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.ShardName:bridge.ShardName.
Internal implementation code; this is not a standalone script.
case "shardname":
case "profileshardname": return new InjectionValue(bridge.ShardName);Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
dynamic UO.ShardPath();Reads the path of the current profile.
There are no parameters.
string — text of the bridge field.CurrentProfilePath; without available data, an empty string is possible. This is not a connection sign and is not a numeric ID.
- ExecuteClientApiCompatibility returns bridge.CurrentProfilePath without changing the profile or server selection.
- Reads the current local state. There is no package, target or automatic update; individual reads may see different states.
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 result of one call is printed in the journal. A number is not converted to bool; an array is displayed as its element count.
object? result = UO.ShardPath();
UO.Print(result is Array values ? "Count: " + values.Length : Convert.ToString(result));Parameters and execution flow:
- Reads the path of the current profile.
var value = UO.ShardPath();
UO.Print(value);Parameters and execution flow:
- ExecuteClientApiCompatibility returns bridge.CurrentProfilePath without changing the profile or server selection.
return RunScenario();
object? RunScenario()
{
var value = UO.ShardPath();
if (Truth(Len(value) > 0))
{
UO.TextPrint(value);
}
return null;
}
int Len(object? value) => Convert.ToString(value)?.Length ?? 0;
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:
- Reads the current local state. There is no package, target or automatic update; individual reads may see different states.
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 before = UO.ShardPath();
UO.Wait(500);
var after = UO.ShardPath();
UO.Print(before = after);
return null;
}
}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: dynamic / Any.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.CurrentProfilePath:bridge.CurrentProfilePath.
Internal implementation code; this is not a standalone script.
case "shardpath":
case "clientprofilepath": return new InjectionValue(bridge.CurrentProfilePath);ClassicUO — Bad Newbie & C# Scripts IDE