Hooks called by Vendors

Summary

Hooks

Lets plugins change the price of an item at a vendor.
Called on the server after a player has bought an item from a vendor: the item is in their inventory and the money has changed hands.
Decides whether a player may buy an item from a vendor.
Decides whether a player may sell an item to a vendor.
Decides whether a player may trade with a vendor.
Called on the server after a player has sold an item to a vendor: the item has been taken from their inventory and removed, and the money has changed hands.
Called on the server before a vendor says one of its phrases to a player.

Hooks

AdjustVendorPrice(actor, vendor, item_obj, price_info)

server plugins/vendors/plugin/lib/sv_pricing.lua:38

Lets plugins change the price of an item at a vendor. Called on the server whenever a price is worked out: for every listed item when the trade panel is opened or updated, and again when an item is bought or sold. Change price_info.price; the result is rounded to the decimals of the currency (down when the vendor is the one who pays) and is never below 0. Return nothing, so that other handlers get to adjust the price too.

Parameters

  • actor Player The customer; nil when a price is asked for without one
  • vendor Entity The vendor
  • item_obj Item The item: its template when the vendor sells it, the instance of the customer when the vendor buys it
  • price_info Map The price to change in place: price (Number), and for reference base_price (Number, the price before any adjustment), selling (Boolean, true if the vendor sells the item and false if it buys it) and currency (String currency ID)

Called from

  • adjust_price

Call sites

CanItemTransfer(item_table, inventory)

server plugins/vendors/plugin/lib/sv_trade.lua:96

No documentation available.

Arguments

  • item_table
  • inventory

Called from

Call sites

CanPlayerDropItem(actor, item_obj)

server plugins/vendors/plugin/lib/sv_trade.lua:195

No documentation available.

Arguments

  • actor
  • item_obj

Called from

Call sites

ItemTransferred(item_obj, nil, inventory)

server plugins/vendors/plugin/lib/sv_trade.lua:252

No documentation available.

Arguments

  • item_obj
  • nil
  • inventory

Called from

Call sites

PlayerBoughtFromVendor(actor, vendor, item_obj, price)

server plugins/vendors/plugin/lib/sv_trade.lua:151

Called on the server after a player has bought an item from a vendor: the item is in their inventory and the money has changed hands.

Parameters

  • actor Player The customer
  • vendor Entity The vendor
  • item_obj Item The new item instance
  • price Number What the player has paid

Called from

Call sites

PlayerCanBuyFromVendor(actor, vendor, item_table, price)

server plugins/vendors/plugin/lib/sv_trade.lua:78

Decides whether a player may buy an item from a vendor. Called on the server once the vendor is known to sell the item and to have it in stock, before the money and the inventory of the player are checked.

Parameters

  • actor Player The customer
  • vendor Entity The vendor
  • item_table Item The template of the item
  • price Number What the player is going to pay

Returns

  • Boolean Return false to refuse the purchase
  • String Error phrase to notify the player with
  • Map Arguments of that phrase

Called from

Call sites

PlayerCanSellToVendor(actor, vendor, item_obj, price)

server plugins/vendors/plugin/lib/sv_trade.lua:211

Decides whether a player may sell an item to a vendor. Called on the server once the vendor is known to take the item, before its money pool is checked.

Parameters

  • actor Player The customer
  • vendor Entity The vendor
  • item_obj Item The item instance of the player
  • price Number What the player is going to be paid

Returns

  • Boolean Return false to refuse the sale
  • String Error phrase to notify the player with
  • Map Arguments of that phrase

Called from

Call sites

PlayerCanUseVendor(actor, vendor)

server plugins/vendors/plugin/lib/sv_sessions.lua:39

Decides whether a player may trade with a vendor. Called on the server when a player uses a vendor and again before every purchase and sale.

Parameters

  • actor Player The customer
  • vendor Entity The vendor

Returns

  • Boolean Return false to refuse the player and true to let them trade whatever the factions of the vendor are; nothing leaves it to those
  • String Error phrase to notify a refused player with instead of the 'refuse' phrase of the vendor
  • Map Arguments of that phrase

Called from

Call sites

PlayerSoldToVendor(actor, vendor, item_obj, paid)

server plugins/vendors/plugin/lib/sv_trade.lua:274

Called on the server after a player has sold an item to a vendor: the item has been taken from their inventory and removed, and the money has changed hands.

Parameters

  • actor Player The customer
  • vendor Entity The vendor
  • item_obj Item The item instance that was sold; it does not exist anymore
  • price Number What the player has been paid, after the AdjustReceivedMoney hook

Called from

Call sites

PreItemTransfer(item_obj, nil, inventory)

server plugins/vendors/plugin/lib/sv_trade.lua:238

No documentation available.

Arguments

  • item_obj
  • nil
  • inventory

Called from

Call sites

VendorSay(vendor, actor, id, text)

server plugins/vendors/plugin/lib/sv_talk.lua:33

Called on the server before a vendor says one of its phrases to a player.

Parameters

  • vendor Entity The vendor
  • actor Player The player the vendor talks to
  • id String Phrase ID: 'greeting', 'refuse', 'no_money', 'no_stock', 'broke' or 'thanks'
  • text String What the vendor is about to say

Returns

  • Boolean Return false to keep the vendor silent
  • String Text to say instead

Called from

Call sites

Defined in