📈 FourTwenty DynMarket - Dynamic Market System & Real-time Economy

:chart_with_upwards_trend: FourTwenty DynMarket - Dynamic Market System & Real-time Economy


Watch Showcase Video

Introduction

Hey FiveM Community! :wave:
We’re FourTwenty, and we’re excited to share our advanced dynamic market system! This resource brings unlimited customizable markets to your server with real-time price fluctuations, modern NUI interface, and an engaging economy system. Perfect for servers looking to add dynamic trading and economic gameplay!

Core Features

Advanced Economic System :bar_chart:

  • Dynamic Supply & Demand

    • Prices react to player trading activity
    • Market prices decrease when items are sold frequently
    • Prices recover over time when items aren’t being sold
    • Configurable impact rates and recovery speeds
    • Prevents exploitation through smart price balancing
  • NEW: Counter-Item System :new:

    • Define items that influence other items’ prices
    • Example: When players craft/sell burgers, burger ingredient prices increase
    • Simulates real market dependencies
    • Optional per-item configuration
    • Creates meaningful economic loops
    -- Example Configuration
    {
        name = "Burger Bun",
        item = "ing_bread",
        basePrice = 100,
        counterItem = "burger",     -- Optional: Define a counter item
        counterEffect = 0.05        -- 5% price increase per counter item
    }
    

Dynamic Price System :chart_with_upwards_trend:

  • Real-time Price Fluctuations
    • Base random fluctuations within set boundaries
    • Supply & Demand impact
    • Counter-item effects
    • Time-based recovery
  • Visual Trend Indicators
    • Up/down arrows for price trends
    • Color-coded price changes
    • Supply level indicators
  • Configurable Parameters
    • Set minimum/maximum prices
    • Adjust fluctuation ranges
    • Configure update intervals
  • Price History
    • Track price changes
    • Monitor market trends
    • Analyze economic patterns

Market Management :convenience_store:

  • Unlimited Market Creation
    • Food Markets
    • Resource Traders
    • Fish Markets
    • Pawnshops
    • Custom market types
  • Individual Market Settings
    • Custom locations
    • Unique NPC configurations
    • Market-specific price rules
    • Category organization
  • Visual Customization
    • Custom map blips
    • Market markers
    • NPC appearance
    • UI themes

Modern Interface :computer:

  • Clean Design
    • Responsive dark theme
    • Intuitive layout
    • Smooth animations
  • Real-time Updates
    • Live price changes
    • Supply level indicators
    • Market trend visualization
  • User-Friendly Features
    • Category filtering
    • Bulk item selection
    • Quick sell options
    • Inventory management

How It Works

Supply & Demand System

  1. Base Price Mechanics

    • Every item has a configurable base price
    • Prices fluctuate randomly within set boundaries
    • Supply & Demand modifies these base calculations
  2. Supply Impact

    • Each sale decreases item prices
    • Impact is configurable per market
    • Automatic price recovery over time
    supplyDemand = {
        enabled = true,
        impact = {
            sale = 0.02,        -- 2% price decrease per sale
            recovery = 0.01,     -- 1% recovery when not sold
            maximum = 0.40       -- Maximum 40% impact
        }
    }
    
  3. Counter-Item System

    • Optional feature for creating economic dependencies
    • When counter-items are sold/crafted, base item prices increase
    • Example: Selling processed items (like burgers) increases ingredient prices
    • Fully configurable effect strength and duration
    items = {
        {
            name = "Salmon",
            item = "fish_salmon",
            basePrice = 85,
            counterItem = "sushi",    -- Optional counter item
            counterEffect = 0.04      -- 4% price increase per sushi
        }
    }
    
  4. Price Calculation

    Final Price = Base Price × (1 + Random Fluctuation) × (1 - Supply Impact + Counter Effect)
    
    • All factors are configurable
    • Built-in limits prevent extreme prices
    • Automatic balancing system

Market Configuration Example

["fish_market"] = {
    enabled = true,
    name = "Fish Market",
    blip = {
        sprite = 356,
        color = 59,
        scale = 0.8
    },
    location = {
        coords = vector3(-1816.5, -1193.8, 14.3),
        heading = 319.0,
        npcModel = "s_m_m_linecook"
    },
    priceSettings = {
        minMultiplier = 0.6,
        maxMultiplier = 1.8,
        maxChangePercent = 20,
        supplyDemand = {
            enabled = true,
            impact = {
                sale = 0.02,
                recovery = 0.01,
                maximum = 0.40
            }
        }
    },
    items = {
        {
            name = "Salmon",
            item = "farm_salmon",
            basePrice = 85,
            category = "Premium Fish",
            counterItem = "sushi",
            counterEffect = 0.04
        }
        -- Add more items...
    }
}

Performance

  • Resource Usage
    • 0.0ms when inactive
    • 0.01-0.02ms when active
  • Optimization Features
    • Smart distance checks
    • Efficient database queries
    • Event batching
    • Price calculation optimization
    • Memory usage optimization

Technical Details

Code is accessible    Yes
Subscription-based    No
Lines of code        ~1500+
Requirements         ESX, oxmysql
Support             Yes
Version             1.2.0

Installation

  1. Download from GitHub
  2. Add to your resources folder
  3. Import SQL file:
    fourtwenty_market_prices.sql
    
  4. Add to server.cfg:
    ensure fourtwenty_dynmarket
    
  5. Configure in config.lua
  6. Restart your server

Documentation

  • GitHub Wiki

    • Complete installation guide
    • Configuration examples
    • API documentation
    • Troubleshooting guide
  • Discord Support

    • Active community
    • Direct developer support
    • Regular updates
    • Feature requests

Links

Updates & Support

  • Regular feature updates
  • Bug fixes
  • Community-driven development
  • Active Discord support
  • Open to suggestions

Tags

free market economy esx opensource trading dynamic-prices supply-demand

Made with :green_heart: by FourTwentyDev


Change Log v1.2.0

  • Added Supply & Demand system
  • Implemented Counter-Item feature
  • Enhanced price calculation algorithm
  • Improved performance optimization
  • Added new configuration options
  • Updated documentation
9 Likes

Not in QB available?

2 Likes

really nice release.

1 Like

No, as it says in the tags, it is currently only available for ESX.
We ourselves have no experience with QB.
However, the script is open source, so there should be no problems rewriting it yourself.
If you have problems, you are welcome to come to our Discord server, maybe we can help you.

Hello, a little suggestion for this beautiful script.

Add a possibility to put articles that coordinate together.

Example:

If I sell iron ores, it decreases the metal bars, if I sell metal bars, it increases the iron ores

Hey there!
This feature actually was already planned and will be released right now.
We just updated the post to reflect the changes.

If you find any bugs, or seem to need help, feel free to join our discord! :slight_smile:

Anyway to change the amount we sell?

not at the moment - but i will add this to our backlog

1 Like

wow, reminds me of a game i played Runescape, talking about the Grand Exchange ! :smiley:
Great work!

1 Like

good script

:loudspeaker: FourTwenty DynMarket v1.3.0 Update!

We’re excited to announce the latest enhancements to FourTwenty DynMarket! This update refines our core system with smarter price calculations, more impactful supply/demand mechanics, and extended support for QBCore. Huge thanks to @SuperOxox for implementing QBCore compatibility! :muscle:


What’s New in v1.3.0?

1. Smarter Price Calculations

We’ve reworked the price calculation logic to deliver a more dynamic and realistic market experience.

  • Improved Weighting System:
    The balance between random fluctuations and supply/demand impact has been optimized for better control.

    • Random changes introduce slight unpredictability.
    • Supply/demand impact now has a more significant influence, ensuring prices react properly to player activity.
    Config.PriceCalculation = {
        randomWeight = 0.3,  -- Weight for random price changes
        supplyWeight = 0.7,  -- Weight for supply/demand impact
        minChangeThreshold = 1 -- Minimum price difference to register changes
    }
    

    New Formula:

    Final Price = Current Price + (Random Change × Random Weight) + (Supply Impact × Supply Weight)
    

    This allows for dynamic yet controlled price movements across all markets. Players will notice the effects of their trading behavior more prominently.

2. Enhanced Debugging System :hammer_and_wrench:

To assist in fine-tuning your market settings, we’ve improved the debugging output:

  • Detailed Price Logs:
    Every step of the price calculation is now logged, including:

    • Base prices
    • Current prices
    • Random and supply impact values
    • Combined weighted changes
    • Rounded final prices
    • Price trends

    Example Debug Log:

    === Starting price calculation for farm_pearl in market pawnshop ===
    Base price: 120
    Current price: 167
    Random price change: 4
    Supply impact (price delta): -54
    Weights - Random: 0.30, Supply: 0.70
    Combined price change (weighted): -35.8
    Rounded final price: 113
    Price trend: down
    === Price calculation complete ===
    
  • Debug Mode Levels:
    Adjust your logs to show basic or detailed information, making troubleshooting and performance checks easier.

3. Full QBCore Support

Thanks to @SuperOxox, FourTwenty DynMarket now fully supports QBCore in addition to ESX.

  • Simply set the framework in config.lua:
    Config.Framework = "QBCore" -- or "ESX"
    

Changelog v1.3.0

  • Reworked price calculation logic with updated weighting for random and supply/demand impacts.
  • Enhanced debugging for detailed price behavior tracking.
  • Rounded final prices to ensure no awkward decimals.
  • Added full QBCore support (Thanks, @SuperOxox!).

Updated Core Features

Dynamic Price System

  • Smarter price fluctuations:
    Prices now respond more realistically to player trading activity.
  • Configurable weighting:
    Fine-tune how much randomness and supply/demand impact your market prices.
  • Supply/demand impact duration:
    Configure how long the impact of sales affects the market.

How to Update?

  1. Download the latest release from GitHub.
  2. Replace the old resource files.
  3. Update your Config:
    • Adjust the new Config.PriceCalculation settings.
    • Set Config.Framework to ESX or QBCore.
  4. Restart your server to apply changes.

Special Thanks

Big shoutout to @SuperOxox for contributing QBCore support and helping the community thrive! :green_heart:


1 Like

Thanks for making it for QB, but unfortunately it is not compatible with the QB Inventory.