Stock Market

10k Downloads

StockMarket

StockMarket is a plugin designed to create a virtual and random in game Stock Market that has random events and can be a lot of fun.

You can customize the plugin so in general players will lose money, but the smart ones will come out making money. You can customize it so just about everyone is constantly making money. You can customize it so in general the stocks price stay about the same, with max and min prices so players cannot profit much from it.

Theres lots of random events and always room for more, where stocks prices are affected by certain world events or company events. The frequency of these events can be customized.

All data is stored using mySQL. Support for other DBs including flatfiles and sqlite will come later.

Plugin is currently in alpha (or whatever you want to think of it as).

Dependencies

  • Vault
  • Vault Compatible Economy Plugin
  • MySQL Database

Commands

  • /sm help <page> - Displays StockMarket help. - Permission Node: stockMarket.user.help
  • /sm info - Displays plugin version & status. - Permission Node: stockMarket.user.info
  • /sm list - Displays a list of stocks you are allowed to buy and their current price. - Permission Node: stockMarket.user.list
  • /sm list mine - Displays a list of stocks that you currently own and their current price. - Permission Node: stockMarket.user.list
  • /sm buy <stockID> <amount> - Buys the stock & amount specified. - Permission Node: stockMarket.user.buy
  • /sm sell <stockID> <amount> - Sells the stock & amount specified - Permission Node: stockMarket.user.sell
  • /sm add <stockID> <basePrice> <maxPrice> <minPrice> <volatility> <amount> <dividend> <stockName> - Adds a new stock to the list of all stocks. - Permission Node: stockMarket.admin.add
  • /sm remove <stockID> - Removes an existing stock from the list of all stocks. Cannot be undone. - Permission Node: stockMarket.admin.remove
  • /sm set <stockID> <newBasePrice> <newMaxPrice> <newMinPrice> <newVolatility> <newAmount> <newDividend> <newStockName> - Edits an existing stocks information. - Permission Node: stockMarket.admin.set
  • /sm forcerandom - Forces a random event to occur on a random stock. Does nothing if no stocks exist - Permission Node: stockMarket.admin.event
  • /sm reload - Reloads the plugins config. - Permission Node: stockMarket.admin.reload
  • /sm <stockID> - displays more info about stock requested. - Permission Node: stockMarket.user.detail

Configuration

So right now the plugin is purely MySQL, as stated above support for other formats will be added later. Run the plugin once to generate the default config file. By default the MySQL server is localhost:3306 user: root pass: "" database: sm. If the database does not exist, it will be created. There are a few other options in there as well. :)

This plugin depends on Vault. It also requires that there be an economy plugin and a permissions plugin, else it unloads on start-up.

Adding Stocks

To add a stock use /sm add.

For example:

  • /sm add MASH 100 200 1 100 -1 1 Mashlol's Epic Business of Amazingness
  • /sm add AAPL 500 1000 1 25 500 2 Apple Inc.

In general:

  • /sm add ID BasePrice MaxPrice MinPrice Volatility Amount Dividend (Name Can Continue For As Long As You Want)
Creating Events
    #: <-- This number must follow order (i.e. don't have events 0-3 and 5-7, that would be pointless and also wouldn't work)
       message: Message <-- This message will be displayed when the event occurs.  All instances of %s will be replaced with the Stock ID.
       effect: 50 <-- This is the base effect based on the base price.  I.e. the max price change that can occur if this is 50, is an increase in the stocks price equal to 50% of the base price (that is of course if the volatility of the stock is 100)
       up: true <-- Does this event increase the price or decrease it?  True for increase, false for decrease.
       frequency: 50 <-- This has a chance of 50/(sum of all frequencies) to be selected.  For example if there are 3 events, each with a frequency of 1, they each have a 1/3 chance of occuring.
Default Config
# How many stocks is the player allowed in total?
max-total-stocks-per-player: 250 
# How many stocks is the player allowed of each stock?
max-total-stocks-per-player-per-stock: 50
# How often in minutes should random events occur?
random-event-frequency: 60
# How often in minutes should dividends be paid out?
dividend-frequency: 1440
# Should offline players be paid during dividend payouts?
pay-offline-players: true
# Broadcast events?
broadcast-events: true
# Broadcast dividend payouts?
broadcast-payouts: true
mysql:
    ip: localhost
    port: 3306
    username: root
    password: ""
    database: sm
events:
    0:
       message: "The CEO of %s has died of a heart attack.  The replacement is looking to be a poor one."
       effect: 40
       up: false
       frequency: 50
    1:
       message: "The CEO of %s has died of a heart attack.  The replacement looks like he is even better than his successor!"
       effect: 40
       up: true
       frequency: 50
    2:
       message: "%s has announced a new product to be released!  Speculation is high!"
       effect: 8
       up: true
       frequency: 250
    3:
       message: "%s has announced a new product to be released!  Speculation is high!"
       effect: 8
       up: false
       frequency: 250
    4:
       message: "%s's announced product was a huge success, customers are extremely satisfied!"
       effect: 45
       up: true
       frequency: 250
    5:
       message: "%s's announced product was poorly made, causing poor customer satisfaction!"
       effect: 45
       up: false
       frequency: 250
    6:
       message: "%s had a bad quarter."
       effect: 30
       up: false
       frequency: 100
    7:
       message: "%s had a fantastic quarter."
       effect: 30
       up: true
       frequency: 100
    8:
       message: "Everyone is speculating that %s is soon to come out with an extremely amazing product!"
       effect: 65
       up: true
       frequency: 5
    9:
       message: "%s is on the brink of bankruptcy."
       effect: 65
       up: false
       frequency: 5
    10:
       message: "%s just invented the next best thing since sliced bread!"
       effect: 400
       up: true
       frequency: 1
    11:
       message: "%s just went bankrupt."
       effect: 400
       up: false
       frequency: 1
    12:
       message: "%s just announced that they are replacing their current CEO, who has a bad reputation."
       effect: 25
       up: true
       frequency: 25
    13:
       message: "%s just announced that they are replacing their current CEO, who everyone loves."
       effect: 25
       up: false
       frequency: 25

Misc

Warning

If you decide to test this plugin, I hold no responsibility for any possible bugs. As it is in alpha, there are likely to be exploits and such which may possibly allow a player to abuse the economy. If you run a server that is based solely on economy, you might want to wait until beta or release :)