Repository navigation
EN API UO CountEx
Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
int UO.CountEx(object? objType, object? color, object? container);Returns item units directly inside the container, without traversing nested bags. Ground searches also count matching mobiles/NPCs, one each. FindDistance, FindVertical and Ignore remain effective. Does not change FindItem, FindCount, FindFullQuantity or GetFoundItems.
objType is the graphic/type, not the serial. color is the hue. -1 or 0xFFFF matches any type/hue. container is a container ID: UO.Backpack() for the backpack or UO.Ground() for the ground. Returns int: sum of max(1, Amount); 0 means no matches. Only already received contents are available; bags are not opened automatically.
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());
}ClassicUOInjectionApiBridge.CountDirectItems → MatchesFindIdentity / MatchesFindContainer / MatchesFindMobile.
ClassicUO — Bad Newbie & C# Scripts IDE