Skip to content

API UO SendShopReply en

Codex edited this page Sep 23, 2026 · 1 revision

UO.SendShopReply

ClassicUO / Basic IDE

Home · API · Trading

Submits an item selection to the most recent active NPC vendor offer. The offer determines whether you buy from or sell to the NPC.

Exact syntax

UO.SendShopReply(reply:Any) -> Unit

Parameters

  • reply — String: "serial:quantity"; separate entries with |, ; or comma. = may replace :. Serial is the entry ID from GetShopList, decimal or 0x, not its graphic or vendor ID. Quantity is a positive integer of units, not stacks; omission means 1. Case-insensitive "accept" or "1" confirms the window draft; an empty string cancels with an empty reply.

Returns

Unit: no value, Boolean, total or purchase confirmation is returned. The server decides whether the trade is valid. Check updated items, gold or server messages after submission.

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. SendShopReply

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.

String: "serial:quantity"; separate entries with |, ; or comma. = may replace :. Serial is the entry ID from GetShopList, decimal or 0x, not its graphic or vendor ID. Quantity is a positive integer of units, not stacks; omission means 1. Case-insensitive "accept" or "1" confirms the window draft; an empty string cancels with an empty reply.

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

2. SessionShop.ParseSelection/Reply

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 "".

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.ParseSelection/Reply.

Unit: no value, Boolean, total or purchase confirmation is returned. The server decides whether the trade is valid. Check updated items, gold or server messages after submission.

Examples

Select up to three units from the first entry

# Select up to three units from the first entry
#
# Submits an item selection to the most recent active NPC vendor offer. The offer determines
# whether you buy from or sell to the NPC.
#
# Unit: no value, Boolean, total or purchase confirmation is returned. The server decides
# whether the trade is valid. Check updated items, gold or server messages after submission.

SUB Main()
    # Selects up to 3 units using the actual first entry serial. This buys in a buy offer and sells
    # in a sell offer: check which offer you opened.

    VAR rows = UO.GetShopList()
    IF GetArrayLength(rows) = 0 THEN
        RETURN
    END IF
    VAR amount = CInt(GetWord(rows[0], 3, "|"))
    IF amount > 3 THEN
        amount = 3
    END IF
    IF amount > 0 THEN
        UO.SendShopReply(GetWord(rows[0], 0, "|") + ":" + CStr(amount))
    END IF
END SUB

Parameter and execution notes:

  • Selects up to 3 units using the actual first entry serial. This buys in a buy offer and sells in a sell offer: check which offer you opened.

Select one unit per entry within a budget

# Select one unit per entry within a budget
#
# Submits an item selection to the most recent active NPC vendor offer. The offer determines
# whether you buy from or sell to the NPC.
#
# Unit: no value, Boolean, total or purchase confirmation is returned. The server decides
# whether the trade is valid. Check updated items, gold or server messages after submission.

SUB Main()
    # BUY offers only: budget 30, type 0x0E21. Selects one unit per matching entry when price is
    # positive and fits the remaining budget. | combines entries into one reply.

    VAR budget = 30
    VAR reply = ""
    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 <= budget AND amount > 0 THEN
                IF reply <> "" THEN
                    reply = reply + "|"
                END IF
                reply = reply + GetWord(row, 0, "|") + ":1"
                budget = budget - price
            END IF
        END IF
    NEXT
    IF reply <> "" THEN
        UO.SendShopReply(reply)
    END IF
END SUB

Parameter and execution notes:

  • BUY offers only: budget 30, type 0x0E21. Selects one unit per matching entry when price is positive and fits the remaining budget. | combines entries into one reply.

Confirm the window draft

# Confirm the window draft
#
# Submits an item selection to the most recent active NPC vendor offer. The offer determines
# whether you buy from or sell to the NPC.
#
# Unit: no value, Boolean, total or purchase confirmation is returned. The server decides
# whether the trade is valid. Check updated items, gold or server messages after submission.

SUB Main()
    # First select quantities in the shop window. "accept" sends that draft, which survives closing
    # graphics. With no selection it sends an empty reply. "1" is an acceptance alias, not an item
    # serial.

    UO.SendShopReply("accept")
END SUB

Parameter and execution notes:

  • First select quantities in the shop window. "accept" sends that draft, which survives closing graphics. With no selection it sends an empty reply. "1" is an acceptance alias, not an item serial.

Cancel the offer

# Cancel the offer
#
# Submits an item selection to the most recent active NPC vendor offer. The offer determines
# whether you buy from or sell to the NPC.
#
# Unit: no value, Boolean, total or purchase confirmation is returned. The server decides
# whether the trade is valid. Check updated items, gold or server messages after submission.

SUB Main()
    # An empty string sends an empty reply and closes the active offer. Checking GetShopList avoids
    # calling with no items, but cannot distinguish an empty offer from no offer.

    IF GetArrayLength(UO.GetShopList()) > 0 THEN
        UO.SendShopReply("")
    END IF
END SUB

Parameter and execution notes:

  • An empty string sends an empty reply and closes the active offer. Checking GetShopList avoids calling with no items, but cannot distinguish an empty offer from no offer.

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

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

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

Clone this wiki locally