Repository navigation
EN UO Topic journal Part 2
Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
Home · C# · IDE · UO API · A–Z · Examples · Languages
Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
dynamic UO.WaitJournalLine(object? startTime, object? str, object? maxWaitTimeMS);Waits for a suitable message in the local log.
-
startTime- Required start label: int Now() in milliseconds, 0 - start of execution. Also accepted is double OLE date from LineTime (modern dates 20000…100000 days). Whole 20000…100000 are always milliseconds, not a date. Do not convey the age of the entry. -
str— The searched substring or several alternatives via |, for example success|failed. Spaces at the edges of each alternative are removed, empty alternatives are skipped. This is plain text, not a regular expression. Use a non-empty template. Case insensitive search. -
maxWaitTimeMS— Mandatory int timeout in milliseconds; a positive value limits the wait, 0 means wait without limit. Negative values are limited to 0. Stopping the script interrupts the wait.
bool - true if the text is found, false if there is a positive timeout without a match. This is not an index or a quantity. Boolean values can also be displayed as 1/0 in the script.
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.
- Search and Journal/GetJournal/LastJournalMessage save the text and fields of a single entry in the current script. New messages do not replace these fields. If a record is evicted from a limited journal, the retained fields remain, but LineIndex/GetFoundedTextIndex return -1. The next search or read selects another entry; an unsuccessful search, an invalid index, and clearing through this script reset the selection.
- The initial boundary is fixed when called, polling occurs approximately every 25 ms. The anticipation itself does not trigger the skill or item. LineCount after wait refers to the last search.
- To filter only system strings, use WaitJournalLineSystem.
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.WaitJournalLine(Now(), "success|failed", 3000);
UO.Print(result is Array values ? "Count: " + values.Length : Convert.ToString(result));Parameters and execution flow:
- started — the limit before waiting. 3000 — maximum wait in milliseconds. The pattern contains two outcomes.
- false — text was not found within this period; the server could have used different wording.
var started = Now();
var found = UO.WaitJournalLine(started, "success|failed", 3000);
if (Truth(found))
{
UO.Print(UO.GetFoundedText());
}
else
{
UO.Print("Timeout");
}
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:
- 0 - start of runtime, not disabling timeout. 100 - timeout.
- The found line may already be in the log before the call.
return RunScenario();
object? RunScenario()
{
if (Truth(UO.WaitJournalLine(0, "notice", 100)))
{
var author = UO.LineName();
UO.Print(author);
}
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:
- stamp saves double LineTime without Convert.ToInt32/Convert.ToString: This is a calendar date, not Now(). 1500 — milliseconds to wait.
- The border is turned on. The selected string itself may be suitable if it contains response.
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 text = UO.Journal(0);
if (Truth(UO.LineIndex() >= 0))
{
var stamp = UO.LineTime();
var found = UO.WaitJournalLine(stamp, "response", 1500);
UO.Print(Convert.ToString(found));
}
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: startTime (Any), str (Any), maxWaitTimeMS (Any)
Result: dynamic / Any.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility. -
InjectionScript.Runtime.InjectionApiUO.WaitJournalLine:WaitJournalLine(arguments, false).
Internal implementation code; this is not a standalone script.
case "waitjournalline": return WaitJournalLine(arguments, false);Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
dynamic UO.WaitJournalLineSystem(object? startTime, object? str, object? maxWaitTimeMS);Waits for a suitable message with the name of the author System.
-
startTime- Required start label: int Now() in milliseconds, 0 - start of execution. Also accepted is double OLE date from LineTime (modern dates 20000…100000 days). Whole 20000…100000 are always milliseconds, not a date. Do not convey the age of the entry. -
str— The searched substring or several alternatives via |, for example success|failed. Spaces at the edges of each alternative are removed, empty alternatives are skipped. This is plain text, not a regular expression. Use a non-empty template. Case insensitive search. -
maxWaitTimeMS— Mandatory int timeout in milliseconds; a positive value limits the wait, 0 means wait without limit. Negative values are limited to 0. Stopping the script interrupts the wait.
bool - true if the text is found, false if there is a positive timeout without a match. This is not an index or a quantity. Boolean values can also be displayed as 1/0 in the script.
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.
- Search and Journal/GetJournal/LastJournalMessage save the text and fields of a single entry in the current script. New messages do not replace these fields. If a record is evicted from a limited journal, the retained fields remain, but LineIndex/GetFoundedTextIndex return -1. The next search or read selects another entry; an unsuccessful search, an invalid index, and clearing through this script reset the selection.
- The initial boundary is fixed when called, polling occurs approximately every 25 ms. The anticipation itself does not trigger the skill or item. LineCount after wait refers to the last search.
- In this adaptation, System is identified by the name of the author, case insensitive; The team works with the general journal ClassicUO.
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.WaitJournalLineSystem(Now(), "success|failed", 3000);
UO.Print(result is Array values ? "Count: " + values.Length : Convert.ToString(result));Parameters and execution flow:
- started — the limit before waiting. 3000 — maximum wait in milliseconds. The pattern contains two outcomes.
- false — text was not found within this period; the server could have used different wording.
var started = Now();
var found = UO.WaitJournalLineSystem(started, "success|failed", 3000);
if (Truth(found))
{
UO.Print(UO.GetFoundedText());
}
else
{
UO.Print("Timeout");
}
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:
- 0 - start of runtime, not disabling timeout. 100 - timeout.
- The found line may already be in the log before the call.
return RunScenario();
object? RunScenario()
{
if (Truth(UO.WaitJournalLineSystem(0, "notice", 100)))
{
var author = UO.LineName();
UO.Print(author);
}
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:
- stamp saves double LineTime without Convert.ToInt32/Convert.ToString: This is a calendar date, not Now(). 1500 — milliseconds to wait.
- The border is turned on. The selected string itself may be suitable if it contains response.
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 text = UO.Journal(0);
if (Truth(UO.LineIndex() >= 0))
{
var stamp = UO.LineTime();
var found = UO.WaitJournalLineSystem(stamp, "response", 1500);
UO.Print(Convert.ToString(found));
}
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: startTime (Any), str (Any), maxWaitTimeMS (Any)
Result: dynamic / Any.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility. -
InjectionScript.Runtime.InjectionApiUO.WaitJournalLine:WaitJournalLine(arguments, true).
Internal implementation code; this is not a standalone script.
case "waitjournallinesystem": return WaitJournalLine(arguments, true);Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
void UO.WaitingForJournalText(object? startTime, object? maxDelay, object? text);
void UO.WaitingForJournalText(object? startTime, object? maxDelay, object? text, object? equals);
void UO.WaitingForJournalText(object? startTime, object? maxDelay, object? text, object? equals, object? ignoreCase);
void UO.WaitingForJournalText(object? startTime, object? maxDelay, object? text, object? equals, object? ignoreCase, object? skillNameOrObjectId);Expects text with additional comparison modes and optional skill/item launch.
-
startTime— Mandatory label Now(), int milliseconds from the start of runtime. Lines with a label not less than startTime are checked; 0 includes entries with a zero label. -
maxDelay— Mandatory maximum wait in milliseconds. 0 and negative values mean one immediate pass rather than an infinite wait. -
text— The searched substring or several alternatives via |, for example success|failed. Spaces at the edges of each alternative are removed, empty alternatives are skipped. This is plain text, not a regular expression. Use a non-empty template. -
equals- Optional int: 0 (default) - substring; non-zero value - all text must match one alternative. -
ignoreCase— Optional int: 0 (default) — case sensitive; non-zero - ignore. -
skillNameOrObjectId- Optional skill by name, serial/hex string or resolvable object alias. The name of the skill is recognized first, otherwise the object is used. 0/empty line disables the action. The skill/item is triggered once before searching.
void - no return value, do not assign the call to a variable. When completed, GetFoundedTextIndex >= 0 means that the selected entry is still available; -1 - not found/record deleted. GetFoundedTextID shows the matching alternative only if the selection is successful.
- Search and Journal/GetJournal/LastJournalMessage save the text and fields of a single entry in the current script. New messages do not replace these fields. If a record is evicted from a limited journal, the retained fields remain, but LineIndex/GetFoundedTextIndex return -1. The next search or read selects another entry; an unsuccessful search, an invalid index, and clearing through this script reset the selection.
- Poll with pause up to 25 ms; stopping the script interrupts it. An empty list of alternatives does not find text. For a bool result, use WaitJournalLine with its own parameters and the meaning of a zero timeout.
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.WaitingForJournalText");
UO.WaitingForJournalText(Now(), 2000, "notice");Parameters and execution flow:
- startTime — mark before waiting; maxDelay=2000 ms; case-sensitive substring comparison.
- The command does not return true/false: the selected entry is checked.
var started = Now();
UO.WaitingForJournalText(started, 2000, "notice");
if (Truth(UO.GetFoundedTextIndex() >= 0))
{
UO.Print(UO.GetFoundedText());
}
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:
- startTime=0; maxDelay=0 - one pass. equals=1 — all text, ignoreCase=1 — no case.
- The alternative number 0 or 1 is displayed; a long line with additional words will not work.
return RunScenario();
object? RunScenario()
{
UO.WaitingForJournalText(0, 0, "success|failed", 1, 1);
if (Truth(UO.GetFoundedTextIndex() >= 0))
{
UO.Print(Convert.ToString(UO.GetFoundedTextID()));
}
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:
- The sixth argument of Hiding runs the skill once. equals=0 — substring, ignoreCase=1 — no case.
- The words hidden/failed are examples, replace them with the text of your server. Instead of a skill, you can specify serial or lastobject to use the item.
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 started = Now();
UO.WaitingForJournalText(started, 3000, "hidden|failed", 0, 1, "Hiding");
if (Truth(UO.GetFoundedTextIndex() >= 0))
{
UO.Print(UO.GetFoundedText());
}
return null;
}
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;
private int Now() => global::ClassicUO.CSharp.CSharpScriptContext.Current.Now();
}C# is case sensitive. Use the exact UO name. Compare numeric flags with 0; use bool only where the signature returns bool.
UO.WaitingForJournalText(startTime, maxDelay, text) — UO.WaitingForJournalText(Integer,Integer,String)
Parameters: startTime (Integer), maxDelay (Integer), text (String)
Result: void / Unit.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.WaitingForJournalText. -
InjectionScript.Runtime.InjectionApiUO.WaitingForJournalText:WaitingForJournalText(startTime, maxDelay, text, 0, 0, InjectionValue.Zero).
Internal implementation code; this is not a standalone script.
public void WaitingForJournalText(int startTime, int maxDelay, string text)
=> WaitingForJournalText(startTime, maxDelay, text, 0, 0, InjectionValue.Zero);
UO.WaitingForJournalText(startTime, maxDelay, text, equals) — UO.WaitingForJournalText(Integer,Integer,String,Integer)
Parameters: startTime (Integer), maxDelay (Integer), text (String), equals (Integer)
Result: void / Unit.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.WaitingForJournalText. -
InjectionScript.Runtime.InjectionApiUO.WaitingForJournalText:WaitingForJournalText(startTime, maxDelay, text, equals, 0, InjectionValue.Zero).
Internal implementation code; this is not a standalone script.
public void WaitingForJournalText(int startTime, int maxDelay, string text, int equals)
=> WaitingForJournalText(startTime, maxDelay, text, equals, 0, InjectionValue.Zero);
UO.WaitingForJournalText(startTime, maxDelay, text, equals, ignoreCase) — UO.WaitingForJournalText(Integer,Integer,String,Integer,Integer)
Parameters: startTime (Integer), maxDelay (Integer), text (String), equals (Integer), ignoreCase (Integer)
Result: void / Unit.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.WaitingForJournalText. -
InjectionScript.Runtime.InjectionApiUO.WaitingForJournalText:WaitingForJournalText(startTime, maxDelay, text, equals, ignoreCase, InjectionValue.Zero).
Internal implementation code; this is not a standalone script.
public void WaitingForJournalText(int startTime, int maxDelay, string text, int equals, int ignoreCase)
=> WaitingForJournalText(startTime, maxDelay, text, equals, ignoreCase, InjectionValue.Zero);
UO.WaitingForJournalText(startTime, maxDelay, text, equals, ignoreCase, skillNameOrObjectId) — UO.WaitingForJournalText(Integer,Integer,String,Integer,Integer,Any)
Parameters: startTime (Integer), maxDelay (Integer), text (String), equals (Integer), ignoreCase (Integer), skillNameOrObjectId (Any)
Result: void / Unit.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.WaitingForJournalText. -
InjectionScript.Runtime.InjectionApiUO.SelectJournalEntry:SelectJournalEntry(null). -
InjectionScript.Runtime.InjectionApiUO.TriggerWaitAction:TriggerWaitAction(skillNameOrObjectId). -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.JournalEntryCount:bridge.JournalEntryCount(). -
InjectionScript.Runtime.InjectionApiUO.ReadJournalSnapshot:ReadJournalSnapshot(index). -
InjectionScript.Runtime.InjectionApiUO.JournalEntryTime:JournalEntryTime(entry.Timestamp). -
InjectionScript.Runtime.InjectionApiUO.FindJournalPatternId:FindJournalPatternId(journalText, pattern, exactMatch, caseInsensitive). -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.Wait:bridge.Wait(Math.Min(25, Math.Max(1, timeout))).
Internal implementation code; this is not a standalone script.
public void WaitingForJournalText(int startTime, int maxDelay, string text, int equals, int ignoreCase, InjectionValue skillNameOrObjectId)
{
int timeout = Math.Max(0, maxDelay);
bool exactMatch = equals != 0;
bool caseInsensitive = ignoreCase != 0;
string pattern = text ?? string.Empty;
DateTime deadline = timeSource.Now.AddMilliseconds(timeout);
SelectJournalEntry(null);
TriggerWaitAction(skillNameOrObjectId);
do
{
int journalCount = Math.Max(0, bridge.JournalEntryCount());
for (int index = 0; index < journalCount; index++)
{
JournalEntrySnapshot entry = ReadJournalSnapshot(index);
int lineTime = entry == null ? -1 : JournalEntryTime(entry.Timestamp);
if (lineTime < 0 || lineTime < startTime)
continue;
string journalText = entry.Text;
int matchId = FindJournalPatternId(journalText, pattern, exactMatch, caseInsensitive);
if (matchId >= 0)
{
SelectJournalEntry(entry);
foundedTextId = matchId;
return;
}
}
if (timeSource.Now >= deadline)
break;
bridge.Wait(Math.Min(25, Math.Max(1, timeout)));
}
while (true);
}ClassicUO — Bad Newbie & C# Scripts IDE