Skip to content

EN API UO Str

Codex edited this page Oct 12, 2026 · 4 revisions

Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어

UO.Str

Home · C# · IDE · UO API · A–Z · Examples · Languages

C# signatures

int UO.Str();

Reads the character's current Strength.

Parameters

There are no parameters.

Return value

int — current stat points, 0..65535 in the client model; not percentage, ID, skill, lock mode or bool. 0 also means missing/deleted character or inaccessible object. Compare with the numerical requirement, not == true. This is not a stat cap or a guaranteed base value without modifiers.

Behavior

  • The command takes no arguments. Use the exact signatures above.
  • Reads Player.Strength if Player exists and has not been destroyed; otherwise 0. A dead character present is not a removed object. The stat is not calculated from HP, mana, or stamina.
  • GetStr/GetInt/GetDex accept ObjID. Data PlayerMobile is only available for self; for another serial - 0, even for loaded mobile. Someone else's characteristics are not substituted or guessed.
  • Invoke reads on the game thread with the ability to cancel the wait by script. Does not query status, does not open target, does not send a packet, does not change the characteristic and does not add delay.
  • Each call reads the local data anew. The variable stores the snapshot; individual reads may receive different server updates. A non-zero result does not test the connection. Zero can be a value or no data.
  • Use the exact C# names: UO.Str(), UO.Strength(), UO.GetStr() or UO.GetStrength(). C# names are case sensitive.

Standalone C# scripts

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.

Simple example

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.Str();
UO.Print("Str: " + Convert.ToString(result));

1. Read and display points - direct script

Parameters and execution flow:

  • value stores the numeric result; Convert.ToString just formats it for the journal. There are no arguments or character actions.
var value = UO.Str();
UO.Print("Strength: " + Convert.ToString(value));

2. Compare two images - script function

Parameters and execution flow:

  • before and after separate 1000 ms; UO.Wait added to the example. change=after-before can be positive, zero or negative. By itself, it does not distinguish between all intermediate updates and exit from the world.
return await RunScenarioAsync();
async Task<object?> RunScenarioAsync()
{
    var before = UO.Str();
    await Delay(1000);
    var after = UO.Str();
    var change = after - before;
    UO.Print("Change: " + Convert.ToString(change));
    return null;
}

Task Delay(object? milliseconds) => WaitAsync(checked((int)Convert.ToDouble(milliseconds)));

3. Complete Requirement Validation Function - Script Class

Parameters and execution flow:

  • minimum=80 is an example of a requirement, not a client limit. AttributeAtLeast(minimum) rejects the missing character, reads the characteristic once and returns bool: true or false if >= minimum. The logical meaning is given by the comparison, not the characteristic itself.
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(Truth(AttributeAtLeast(80)) == true))
        {
            UO.Print("Requirement met");
        }
        else
        {
            UO.Print("Requirement not met or no player");
        }

        return null;
    }

    dynamic AttributeAtLeast(dynamic minimum)
    {
        if (Truth(UO.Self() == 0))
        {
            return false;
        }

        var value = UO.Str();
        return value >= minimum;
    }

    bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;
}

Command implementation

C# is case sensitive. Use the exact UO name. Compare numeric flags with 0; use bool only where the signature returns bool.

UO.Str() — UO.Str()

Parameters: No parameters.

Result: int / Integer.

During a call:

Internal implementation code; this is not a standalone script.

case "str": return new InjectionValue(bridge.Strength);

Clone this wiki locally