Vendor
constVendor:object
Defined in: server/api.d.ts:2814
Price lists and purses the server owns, traded on the game’s own shop screen.
A vendor is attached to nothing: open one in front of a player from wherever the gamemode decides the counter is – npcInteract, a dialogue option, a command. The screen is a preview. Its prices come from here, and pressing Trade sends a basket that the server re-prices, settles and moves itself; nothing the client shows is trusted.
Prices count in money units, the amount of the game’s money item.
Type Declaration
Section titled “Type Declaration”close()
Section titled “close()”close(
session):boolean
Takes the trade screen off that player.
Parameters
Section titled “Parameters”session
Section titled “session”number
The session to end.
Returns
Section titled “Returns”boolean
False when the session had already ended.
create()
Section titled “create()”create(
options?):number
Creates a vendor with nothing to sell and nothing it buys.
Parameters
Section titled “Parameters”options?
Section titled “options?”Name, starting purse and whether it buys. All optional.
Returns
Section titled “Returns”number
The vendor id.
destroy()
Section titled “destroy()”destroy(
vendor):boolean
Closes every session at the vendor and forgets it. A deal settles the moment its basket arrives, so none is ever left half done.
Parameters
Section titled “Parameters”vendor
Section titled “vendor”number
The vendor to remove.
Returns
Section titled “Returns”boolean
False when there was no such vendor.
getPurse()
Section titled “getPurse()”getPurse(
vendor):number|null
What a vendor holds.
Parameters
Section titled “Parameters”vendor
Section titled “vendor”number
The vendor to ask about.
Returns
Section titled “Returns”number | null
Money units, or null for a purse that never runs out or a vendor that does not exist.
open()
Section titled “open()”open(
vendor,player,npc?):number
Opens the game’s own trade screen on a player. A player already trading has that session closed with reason 2 first, because the game has one trade screen.
Parameters
Section titled “Parameters”vendor
Section titled “vendor”number
The vendor to trade with.
player
Section titled “player”number
NetworkID of the player to show it to.
number
NetworkID of the NPC who keeps the shop. The screen shows that NPC as the trader; omit it to trade with nobody in particular.
Returns
Section titled “Returns”number
The session id, or 0 when the vendor or the player is gone.
sessionOf()
Section titled “sessionOf()”sessionOf(
player):number
The trading session a player is in.
Parameters
Section titled “Parameters”player
Section titled “player”number
NetworkID of the player to ask about.
Returns
Section titled “Returns”number
The session id, or 0 when they are not trading.
setBuyPrices()
Section titled “setBuyPrices()”setBuyPrices(
vendor,rows):boolean
Replaces what a vendor buys from players and what it pays. Anything not listed is shown at no value and a basket selling it is refused.
Parameters
Section titled “Parameters”vendor
Section titled “vendor”number
The vendor to change.
Everything it buys, at most 128 rows and each item class once. Replaces the old list.
Returns
Section titled “Returns”boolean
False when there is no such vendor.
setPurse()
Section titled “setPurse()”setPurse(
vendor,purse):boolean
Sets what a vendor can pay out. Deals keep it current: what players pay goes in, what they are paid comes out.
Parameters
Section titled “Parameters”vendor
Section titled “vendor”number
The vendor to change.
number | null
Money units it holds, or null for a purse that never runs out.
Returns
Section titled “Returns”boolean
False when there is no such vendor.
setStock()
Section titled “setStock()”setStock(
vendor,rows):boolean
Replaces what a vendor sells. Every player with its screen open sees the new shelf straight away, and a basket priced against the old one is refused.
Parameters
Section titled “Parameters”vendor
Section titled “vendor”number
The vendor to stock.
Everything it sells, at most 128 rows and each item class once. Replaces the old list.
Returns
Section titled “Returns”boolean
False when there is no such vendor.
vendorOf()
Section titled “vendorOf()”vendorOf(
session):number
The vendor a session trades with.
Parameters
Section titled “Parameters”session
Section titled “session”number
The session to ask about.
Returns
Section titled “Returns”number
The vendor id, or 0 when the session has ended.