Skip to content
KCKingdoms Connected Scripting APIScripting guides and API
Global objectServer APIGenerated

Vendor

const Vendor: 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.

close(session): boolean

Takes the trade screen off that player.

number

The session to end.

boolean

False when the session had already ended.

create(options?): number

Creates a vendor with nothing to sell and nothing it buys.

VendorOptions

Name, starting purse and whether it buys. All optional.

number

The vendor id.

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.

number

The vendor to remove.

boolean

False when there was no such vendor.

getPurse(vendor): number | null

What a vendor holds.

number

The vendor to ask about.

number | null

Money units, or null for a purse that never runs out or a vendor that does not exist.

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.

number

The vendor to trade with.

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.

number

The session id, or 0 when the vendor or the player is gone.

sessionOf(player): number

The trading session a player is in.

number

NetworkID of the player to ask about.

number

The session id, or 0 when they are not trading.

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.

number

The vendor to change.

VendorBuyRow[]

Everything it buys, at most 128 rows and each item class once. Replaces the old list.

boolean

False when there is no such vendor.

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.

number

The vendor to change.

number | null

Money units it holds, or null for a purse that never runs out.

boolean

False when there is no such vendor.

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.

number

The vendor to stock.

VendorStockRow[]

Everything it sells, at most 128 rows and each item class once. Replaces the old list.

boolean

False when there is no such vendor.

vendorOf(session): number

The vendor a session trades with.

number

The session to ask about.

number

The vendor id, or 0 when the session has ended.