Repository navigation
EN API UO CancelTarget
Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
Home · C# · IDE · UO API · A–Z · Examples · Languages
void UO.CancelTarget();Cancels the active cursor and clears prepared crosshair responses.
There are no parameters.
void - no return value. Call on a separate line; do not use as true/false, serial or type. Metadata object? for compatible forms does not change the actual result of void.
- Replies already sent to the server are not recalled.
- The local callback target is canceled; For an active server target, a target cancellation is sent.
- The queue is common to the client: its clearing applies to the prepared responses of all procedures.
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.CancelTarget");
UO.CancelTarget();Parameters and execution flow:
- There are no arguments.
- The deferred response to self is removed.
UO.WaitTargetSelf();
UO.CancelTarget();Parameters and execution flow:
- 1445/1690/0 is an example of a new point in the world.
- Old answers are removed before setting a new goal.
return RunScenario();
object? RunScenario()
{
UO.CancelTarget();
UO.WaitTargetXYZ(1445, 1690, 0);
return null;
}Parameters and execution flow:
- UO.Wait=1000 ms is a limitation of this example.
- The remaining queue is checked, not the success of the skill. If there is no server crosshair, the next foreign command will not receive the old response.
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.WaitTargetSelf();
UO.UseSkill("Anatomy");
await Delay(1000);
if (Truth(UO.IsWaitTargetActive()))
{
UO.CancelTarget();
}
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: void / Unit.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.CancelTarget. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.GetWaitTargetQueue:bridge.GetWaitTargetQueue(). -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.IsTargeting:bridge.IsTargeting(). -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.CancelTarget:bridge.CancelTarget(). -
InjectionScript.Runtime.InjectionApiUO.SystemMessage:SystemMessage("Targeting cancelled").
Internal implementation code; this is not a standalone script.
public void CancelTarget()
{
var waitTargetQueue = bridge.GetWaitTargetQueue();
if (waitTargetQueue.Length > 0 || bridge.IsTargeting() != 0)
{
bridge.CancelTarget();
SystemMessage("Targeting cancelled");
}
else
SystemMessage("Error: no target to cancel");
}ClassicUO — Bad Newbie & C# Scripts IDE