Skip to content

API UO GetShopList en

Codex edited this page Sep 23, 2026 · 1 revision

UO.GetShopList

ClassicUO / Basic IDE

Home · API · Trading

Reads the items in the most recent active NPC vendor offer, so a script can check type, quantity and price before buying or selling.

Exact syntax

UO.GetShopList() -> Any

Parameters

No parameters.

Returns

Array of String, indexed from 0. Each row is serial|graphic|hue|amount|price|name. Serial identifies an individual offer entry; graphic is its type and hue its color. These three fields use 0x notation. Amount is available units minus the window draft; price is per unit. No offer returns an empty array, not Boolean. A name may contain |: only the first five separators delimit fields, and everything after them is the name.

Behavior

  • First open buying or selling with the intended NPC through a game action and wait for its server offer. These commands do not find a vendor, open trade, price a personal vendor item or move items between containers. There is no vendor-ID argument: the most recent offer is used.
  • The manager keeps the offer in the game session. Closing graphics retains the offer and draft; reopening restores the view. Closing the shop itself, replying, server closure or disconnection removes it. Bad Newbie automatic buying/selling can handle the offer before a script.
  • Reading sends no packets. This is a snapshot of received data, not guaranteed current NPC stock. Amount counts units; GetArrayLength(rows) counts entries. GetShopList reads prices; SendShopReply does not accept a price.
  • An explicit list replaces the draft. Repeated serials add quantities, capped at the full offered amount. Unknown serials, invalid or nonpositive quantities reject the entire reply before sending and preserve the offer. SendShopReply reports an error without an offer. "0" is not cancellation: use "".

Internal functions: from call to result

SessionShops validates complete server lists/prices and stores the offer. The bridge dispatches on the session thread. SessionShop.GetItems formats rows; ParseSelection validates the selection; Reply sends buy packet 0x3B or sell packet 0x9F and closes the offer. ShopGump displays the same data and preserves quantities and scroll when detached. A server close never echoes another reply.

1. GetShopList

First open buying or selling with the intended NPC through a game action and wait for its server offer. These commands do not find a vendor, open trade, price a personal vendor item or move items between containers. There is no vendor-ID argument: the most recent offer is used.

Array of String, indexed from 0. Each row is serial|graphic|hue|amount|price|name. Serial identifies an individual offer entry; graphic is its type and hue its color. These three fields use 0x notation. Amount is available units minus the window draft; price is per unit. No offer returns an empty array, not Boolean. A name may contain |: only the first five separators delimit fields, and everything after them is the name.

Project source: src/ClassicUO.Client/Game/Managers/ClassicUOInjectionApiBridge.cs; function GetShopList.

2. SessionShop.GetItems

Reading sends no packets. This is a snapshot of received data, not guaranteed current NPC stock. Amount counts units; GetArrayLength(rows) counts entries. GetShopList reads prices; SendShopReply does not accept a price.

The manager keeps the offer in the game session. Closing graphics retains the offer and draft; reopening restores the view. Closing the shop itself, replying, server closure or disconnection removes it. Bad Newbie automatic buying/selling can handle the offer before a script.

Project source: src/ClassicUO.Client/Game/Managers/SessionShops.cs; function SessionShop.GetItems.

Reading sends no packets. This is a snapshot of received data, not guaranteed current NPC stock. Amount counts units; GetArrayLength(rows) counts entries. GetShopList reads prices; SendShopReply does not accept a price.

Examples

Read fields from the first entry

# Read fields from the first entry
#
# Reads the items in the most recent active NPC vendor offer, so a script can check type,
# quantity and price before buying or selling.
#
# Array of String, indexed from 0. Each row is serial|graphic|hue|amount|price|name. Serial
# identifies an individual offer entry; graphic is its type and hue its color. These three
# fields use 0x notation. Amount is available units minus the window draft; price is per unit.
# No offer returns an empty array, not Boolean. A name may contain |: only the first five
# separators delimit fields, and everything after them is the name.

SUB Main()
    # GetWord uses zero-based fields: 0 serial, 1 graphic, 2 hue, 3 amount, 4 price. Check the array
    # length before rows[0].

    VAR rows = UO.GetShopList()
    IF GetArrayLength(rows) = 0 THEN
        RETURN
    END IF
    VAR serial = GetWord(rows[0], 0, "|")
    VAR itemType = GetWord(rows[0], 1, "|")
    VAR amount = CInt(GetWord(rows[0], 3, "|"))
    VAR price = CDbl(GetWord(rows[0], 4, "|"))
    UO.Print(serial + " / " + itemType + " / " + CStr(amount) + " / " + CStr(price))
END SUB

Parameter and execution notes:

  • GetWord uses zero-based fields: 0 serial, 1 graphic, 2 hue, 3 amount, 4 price. Check the array length before rows[0].

Buy up to ten bandages below a price limit

# Buy up to ten bandages below a price limit
#
# Reads the items in the most recent active NPC vendor offer, so a script can check type,
# quantity and price before buying or selling.
#
# Array of String, indexed from 0. Each row is serial|graphic|hue|amount|price|name. Serial
# identifies an individual offer entry; graphic is its type and hue its color. These three
# fields use 0x notation. Amount is available units minus the window draft; price is per unit.
# No offer returns an empty array, not Boolean. A name may contain |: only the first five
# separators delimit fields, and everything after them is the name.

SUB Main()
    # Requires an already opened BUY offer. 0x0E21 is bandages, 5 the maximum unit price, 10 the
    # desired amount. Uses the first matching entry and its actual serial. It does not open buying.

    VAR rows = UO.GetShopList()
    FOR VAR i = 0 TO GetArrayLength(rows) - 1
        VAR row = rows[i]
        IF GetWord(row, 1, "|") = "0x0E21" THEN
            VAR price = CDbl(GetWord(row, 4, "|"))
            VAR amount = CInt(GetWord(row, 3, "|"))
            IF price > 0 AND price <= 5 AND amount > 0 THEN
                IF amount > 10 THEN
                    amount = 10
                END IF
                UO.SendShopReply(GetWord(row, 0, "|") + ":" + CStr(amount))
                RETURN
            END IF
        END IF
    NEXT
END SUB

Parameter and execution notes:

  • Requires an already opened BUY offer. 0x0E21 is bandages, 5 the maximum unit price, 10 the desired amount. Uses the first matching entry and its actual serial. It does not open buying.

Count available units of a type

# Count available units of a type
#
# Reads the items in the most recent active NPC vendor offer, so a script can check type,
# quantity and price before buying or selling.
#
# Array of String, indexed from 0. Each row is serial|graphic|hue|amount|price|name. Serial
# identifies an individual offer entry; graphic is its type and hue its color. These three
# fields use 0x notation. Amount is available units minus the window draft; price is per unit.
# No offer returns an empty array, not Boolean. A name may contain |: only the first five
# separators delimit fields, and everything after them is the name.

SUB Main()
    # The complete helper sums amount for every matching type. Empty offers return 0. This is
    # available units, not the count of creatures or items on your character.

    VAR available = CountOfferedType("0x0E21")
    IF available < 10 THEN
        UO.Print("Bandage stock below 10: " + CStr(available))
    END IF
END SUB

FUNCTION CountOfferedType(itemType)
    VAR total = 0
    VAR rows = UO.GetShopList()
    FOR VAR i = 0 TO GetArrayLength(rows) - 1
        IF GetWord(rows[i], 1, "|") = itemType THEN
            total = total + CInt(GetWord(rows[i], 3, "|"))
        END IF
    NEXT
    RETURN total
END FUNCTION

Parameter and execution notes:

  • The complete helper sums amount for every matching type. Empty offers return 0. This is available units, not the count of creatures or items on your character.

Shop lists / Списки покупки и продажи

Shop lists / Списки покупки и продажи

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

Clone this wiki locally