Vendor
Shops stored on the server and traded through the game's shop screen. A vendor has a shelf of priced rows, a list of what it pays for players' items, and a purse. Prices are in units of the game's money item. The client only estimates. When the player confirms, the server recalculates from its own data and either completes the trade or refuses it, for example because stock changed, someone lacks money, or there is no space. A player can use one vendor at a time. Events are vendorTrade(vendor, player, bought, sold, balance) and vendorClosed(vendor, player, reason), where the reason is 0 closed by the player, 1 by the server, 2 replaced by another vendor, 3 failed to open, or 4 the player disconnected.
vendor.create()
Vendor.create(options)Creates a vendor and returns its id.
vendor.destroy()
Vendor.destroy(vendor)Removes a vendor and closes open screens. Returns false if there is no such vendor.
vendor.setShelf()
Vendor.setShelf(vendor, rows)Replaces the shelf, with up to 128 rows.
vendor.setOffers()
Vendor.setOffers(vendor, rows)Sets what the vendor pays per unit for players' items, up to 128 rows. It does not buy items left out.
vendor.fillPurse()
Vendor.fillPurse(vendor, purse)Sets how much money the vendor has. null means unlimited.
vendor.purseOf()
Vendor.purseOf(vendor)The vendor's money, or null for an endless purse.
vendor.open()
Vendor.open(vendor, player, npc)Opens the shop screen for a player and returns the session id, or 0 if the vendor or player is gone.
vendor.close()
Vendor.close(session)Closes a session's screen. Returns false if the session has ended.
vendor.activeSession()
Vendor.activeSession(player)The player's open session id, or 0.
vendor.shopOf()
Vendor.shopOf(session)A session's vendor, or 0.