Skip to content

DE API UO CountEx

Codex edited this page Oct 17, 2026 · 3 revisions

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

UO.CountEx

int UO.CountEx(object? objType, object? color, object? container);

Zählt Gegenstandseinheiten direkt im Behälter, ohne verschachtelte Taschen zu durchsuchen. Bei Bodensuche zählen auch passende Figuren/NPCs jeweils als eine Einheit. FindDistance, FindVertical und Ignore gelten weiterhin. FindItem, FindCount, FindFullQuantity und GetFoundItems bleiben unverändert.

objType ist die Grafik/type, nicht die Seriennummer; color ist der Farbton. -1 oder 0xFFFF erlaubt jeden Typ/Farbton. container ist die Behälter-ID: UO.Backpack() für den Rucksack, UO.Ground() für den Boden. Rückgabe int: Summe von max(1, Amount), 0 bei keinem Treffer. Nur bereits empfangene Inhalte werden berücksichtigt; Taschen werden nicht automatisch geöffnet.

Beispiele

int goldUnits = UO.CountEx(0x0EED, -1, UO.Backpack());
UO.Print(goldUnits.ToString());
UO.FindTypeEx(0x0EED, -1, UO.Backpack(), false);
int previousFoundItem = UO.FindItem();
int bandages = UO.CountEx(0x0E21, -1, UO.Backpack());
bool searchPreserved = UO.FindItem() == previousFoundItem;
UO.Print($"{bandages}; {searchPreserved}");
int units = CountBackpackUnits(0x0EED);
UO.Print(units.ToString());

int CountBackpackUnits(int graphic)
{
    return UO.CountEx(graphic, -1, UO.Backpack());
}
var counter = new InventoryCounter(UO);
UO.Print(counter.CountGold().ToString());

class InventoryCounter(ClassicUO.CSharp.CSharpGameApi api)
{
    public int CountGold() => api.CountEx(0x0EED, -1, api.Backpack());
}

Implementierung

ClassicUOInjectionApiBridge.CountDirectItems → MatchesFindIdentity / MatchesFindContainer / MatchesFindMobile.

Clone this wiki locally