$ man tshabbic.projects.rct-ah
RCT-AH(8)Server Side Auction HouseRCT-AH(8)
Name

rct-ah -- server side auction house

Description

[See the Source Code!]

This TShock for Terraria plugin provides users with the ability to place their hard-earned items on a global, server-side auction house where other players can buy from using a centralized server-currency that is earned by various means.

Users are allowed to list up to 15 items at once, with the Auction House itself housing a maximum of 1000 items total and is easily extendable.

The trickier part of an auction house is that buyers and sellers are rarely online at the same time. If the seller happens to be online when their item sells, great, they're simply paid on the spot, nice and easy; otherwise, due to an limitation of our server-side currency plugin, the payment must be placed in a queue and handed over the next time they log in, so a sale is never lost just because nobody was around to receive it.

Unsold listings follow the same idea in reverse. After 7 days, an item goes back to its owner (along with the 5% deposit required to list it) on their next login, but if their inventory is full at that moment, I chose to leave the item on the auction house until they've made room rather than risk dropping it on the ground or deleting it.

Since all of this involves a server's currency, I also wanted staff to be able to keep an eye on things without digging through files. Listings and purchases are posted to a private staff Discord channel as they happen, with returns, payouts, and expirations recorded in the server's log, so when a player claims something went missing, a moderator can usually trace what happened to a listing without ever needing access to the server itself.

Usage
/ah <option>. Options: buy, sell, bump, pull, list, search, help


Permission required: ah.use

Opens the Auction House, where players can list items for sale and buy items listed by others, paying with SEconomy currency. Also available as /auction and /auctionhouse. Buying and selling require being logged in and alive, with an enabled bank account.


Sub-commands:

/ah sell <price>

Lists the item stack you are currently holding for the specified price. The price accepts coin shorthand, so 4p36g52s28c works. A 5% deposit is taken when you list. Each player can have at most 15 listings at a time, and the Auction House holds at most 1000 in total.

/ah buy <id>

Buys the listing with the specified ID at its listed price. Requires enough money and a free inventory slot, and you cannot buy your own listings. The seller is paid the price plus their deposit back, immediately if they are online, or on their next login if not. Fallen Stars cannot be bought between 4:30 AM and 7:29 PM (in-game time).

/ah list [page]

Lists every listing on the Auction House, newest first, 9 per page. Your own listings are highlighted in purple. In the time column, green is the time until the listing is returned to its seller if unsold; red means the return date has passed and shows the time until the listing expires.

/ah list own [page]

Same layout as /ah list, but only shows your own listings.

/ah search <item1> ... <item5> [page]


Lists the listings whose item name contains any of the given terms (case-insensitive). Accepts up to 5 unique terms, followed by an optional page number.

/ah bump <id>

Resets one of your listings to its freshly-listed state: a new 7 day return date and 15 day expiration. Can only be done once the listing has less than 3 days left before its return date.

/ah pull <id>

Takes one of your listings off the Auction House and gives the item(s) back. Requires a free inventory slot. The deposit is not refunded for pulled listings.

/ah help

Prints the in-game help text along with a summary of the rules.


Listing lifecycle:

If a listing has not sold after 7 days, the item(s) and deposit are returned to the seller the next time they log in or anyone runs /ah, provided the seller has inventory space. Listings are removed entirely after 15 days, which leaves 8 days to reclaim an unsold item. Anything not reclaimed by then, along with its deposit, is lost.


Administrative sub-commands (permission required: ah.admin):

/ah save

Writes the current Auction House data to disk.

/ah load

Reloads the Auction House data from disk, replacing what is currently in memory.

/ah freeze

Toggles a freeze. While frozen, players without ah.admin cannot use /ah, and the login-time checks for returned listings and queued payments are skipped. Run it again to unfreeze.

/ah debug <[p]ayments | [l]istings>


Prints the raw payment queue, or every listing with its full details (return and expiration dates, lister account).

/ah pull <id> [-f]orce

Removes any player's listing. The item(s) are deleted rather than returned to anyone, and no deposit is refunded.

Bugs

Every time a new listing is added to the auction house, its numeric identifier is incremented by one from the previous listing's ID. This means that over time, users will need to type in more numbers to correctly specify their desired listing. While this does guarantee that there can never be a collision in terms of identifiers, it certainly can be rewritten to always attempt to take the lowest available identifier for the convenience of the user.

History

This plugin was written out of boredom in preparation for RenCorner Terraria's Survival server during Summer of 2024 and was written for TShock 5.2.4.0 on .NET 6.0 for Terraria 1.4.4.9.