This script provides a complete stock market experience with real-time data integration, dynamic price fluctuations, and immersive RP events that create a living economy for your server.
Features
Real-time Stock Data
Connect to real-world stock data sources for authentic market behavior and price movements.
Randomized Fluctuations
Dynamic price changes with configurable volatility and maximum change percentages for in-game economy.
RP Event System
Create in-game events that affect stock prices, adding depth and immersion to your server’s economy.
Dividend System
Earn passive income from your investments with configurable dividend payouts and intervals.
Admin Controls
Full control over stock behavior, events, and market conditions through comprehensive admin tools.
Player Portfolios
Track investments and performance over time with detailed portfolio management and analytics.
Installation
1
Download
Get the latest release from our Tebex Store and download it from your Keymaster
2
Extract
Extract the script folder to your server’s
resources
directory3
Configure
Add
ensure spooni_stockmarket
to your server.cfg
4
Customize
Configure the script to your liking using the configuration options
5
Restart
Restart your server to activate the stock market system
Configuration
The script is highly configurable through theconfig/config_stockmarket.lua
file. Here are the main configuration sections:
General Settings
config.lua
Administration Settings
config.lua
To set up admin permissions, add the following line to your
server.cfg
:Custom Data Sources
config.lua
Custom data sources should only be used if you understand how they affect stock pricing. Incorrect implementation can lead to unstable market behavior.
Command Configuration
config.lua
Location-Based Access
config.lua
The prompt key
0x760A9C6F
corresponds to the G
key. You can change this to any other key code as needed.Database Setup
The database is created automatically when the resource is started. The system includes the following tables:- stocks: Stock definitions and configuration
- player_portfolios: Player investment tracking
- transactions: Trade history and audit trail
- dividends: Dividend payout records
The database structure is automatically managed by the script. No manual database setup is required.
Sample Stocks
Here are 5 sample stocks you can add to your database after starting the script for the first time:Real-time Stock Symbols
You can choose from over 100 real-world stock symbols. Here are some popular options:Technology Stocks
Technology Stocks
AAPL, MSFT, GOOGL, GOOG, NVDA, META, TSLA, ADBE, CRM, INTC, QCOM, IBM, ORCL, NOW, PANW
Financial Stocks
Financial Stocks
BRK.B, JPM, V, MA, BAC, WFC, GS, C, MS, SCHW, AXP, BLK, SPGI, CB, MMC
Healthcare Stocks
Healthcare Stocks
UNH, JNJ, PFE, LLY, ABBV, MRK, ABT, TMO, DHR, BMY, GILD, MDT, SYK, ISRG, VRTX
Consumer Stocks
Consumer Stocks
AMZN, HD, WMT, MCD, SBUX, TGT, TJX, COST, MCD, DIS, NFLX, NKE, PM, MO
Energy & Industrial
Energy & Industrial
XOM, CVX, COP, NEE, DUK, SO, CAT, LMT, RTX, NOC, HON, DE, UPS, FDX
To request specific stock symbols or get the complete list, please visit our Discord server.
Database Table Structure
The stock market system uses a database table calledstocks
to store all stock configurations. Each stock is defined by a single row in this table with the following fields:
Stock Table Fields
Basic Information
Basic Information
- id (string): Unique stock identifier (e.g., “VCC”, “AMCO”)
- label (string): Display name shown to players (e.g., “Valentine Coal Co.”)
- description (string): Detailed description of the company/stock
- base_price (integer): Initial stock price when first created
- volatility (float): Price volatility multiplier (1.0 = normal, 2.0 = double volatility)
- enabled (boolean): Whether the stock is active and tradeable
Stock Type Configuration
Stock Type Configuration
- type (string): Stock calculation method - “realtime”, “random”, “custom”, or “mixed”
- realtime_source (string): API provider name for real-time data (e.g., “api_provider”)
- realtime_symbol (string): Stock symbol for real-time data (e.g., “AAPL”, “TSLA”)
- realtime_weight (float): Influence of real-time data on price (0.0 to 1.0)
- random_enabled (boolean): Enable random price fluctuations
- random_weight (float): Influence of random fluctuations on price (0.0 to 1.0)
- random_max_change (float): Maximum percentage change per update cycle
- custom_weight (float): Influence of custom data sources on price (0.0 to 1.0)
Item Integration
Item Integration
- Currently disabled
Dividend Settings
Dividend Settings
- dividends_enabled (boolean): Enable dividend payouts for this stock
- dividends_mode (string): “fixed” for set amount or “percent” for percentage
- dividends_amount (float): Fixed dividend amount (used when mode is “fixed”)
- dividends_percent (float): Dividend percentage (used when mode is “percent”)
RP Events
RP Events
- rp_events_enabled (boolean): Enable RP events to affect this stock’s price
Stock Type Examples
Real-time Stock
Real-time Stock
Random Stock
Random Stock
Mixed Stock
Mixed Stock
Custom Stock
Custom Stock
Database Usage Examples
Creating a Real-time Stock
Creating a Randomized Stock
Creating a Mixed Mode Stock
Updating Stock Settings
Performance Considerations
The script is optimized for performance with several key features:
- Efficient Database Queries: Optimized database operations for large datasets
- Configurable Update Intervals: Control how often prices update to balance accuracy and performance
- Caching System: Price data is cached to reduce API calls
- Batch Processing: Multiple operations are processed in batches
Performance Tips
- Update Intervals: Set appropriate price update intervals (12 hours recommended)
- Stock Count: Limit the number of active stocks to essential ones
- API Limits: Be mindful of real-time API rate limits
- Database Maintenance: Regularly clean old transaction records
Troubleshooting
Stocks not updating
Stocks not updating
Check the price update interval configuration, verify API connections for real-time stocks, and ensure the script is properly started in server.cfg.
Real-time data not working
Real-time data not working
Verify API credentials are correct, check network connectivity, and ensure the stock symbol is valid and supported.
Dividends not paying
Dividends not paying
Check dividend configuration settings, verify the payout day is set correctly, and ensure dividends are enabled for the specific stock.
Player portfolios not saving
Player portfolios not saving
Verify database connectivity, check for database errors in console, and ensure the database tables were created properly.
RP events not affecting prices
RP events not affecting prices
Confirm RP events are enabled in configuration, check event trigger conditions, and verify the event system is properly integrated.
Admin commands not working
Admin commands not working
Verify admin permissions are set correctly in server.cfg and check the isAdmin function configuration in config.lua.
Location access not working
Location access not working
Check the coordinates and distance settings in Config.Locations, verify the prompt key is correct, and ensure the location is properly configured.
Framework Integration
The script includes built-in support for multiple frameworks:Limitations
Be aware of the following limitations when configuring the script:
- API Rate Limits: Real-time data sources may have rate limits
- Stock Symbol Availability: Not all stock symbols may be available
- Database Performance: Large transaction histories may impact performance