Skip to main content
Proper resource loading order is critical for Mythic Framework to function correctly. Resources have dependencies on each other, and loading them in the wrong order will cause failures.

Why Load Order Matters

Mythic Framework uses a component-based architecture where resources register components that other resources depend on. If a resource tries to use a component before it’s registered, it will fail.

Dependency Chain

Resources depend on components from other resources. Load dependencies first.

Component Registration

Components must be registered before other resources can fetch them.

Database Access

Core resources need database connection established early.

Event Handlers

Event handlers registered in load order - later resources can override earlier ones.

Resource Load Order

The correct load order is defined in configs/resources.cfg:

1. Database Layer (FIRST)

# Database MUST load before anything else
ensure oxmysql
Critical: oxmysql MUST be the first resource loaded. All other resources depend on database connectivity.

2. Core Framework

# mythic-base: Core framework - MUST load second
ensure mythic-base

# mythic-pwnzor: Anti-cheat - Load early for protection
ensure mythic-pwnzor
mythic-base contains the proxy system, logger, database wrapper, and all core components. Nothing works without it.

3. Queue and Loadscreen

# Player queue system
ensure mythic-queue

# Loading screen shown to connecting players
ensure mythic-loadscreen
These handle the connection flow before players enter the game.

4. Character System

# Character creation and management - Required by most features
ensure mythic-characters
Dependency Alert: Almost ALL gameplay resources depend on the Characters component. Load this before any gameplay features.

5. Core Systems

# Core gameplay systems in dependency order
ensure mythic-inventory    # Required by: shops, crafting, jobs
ensure mythic-finance      # Required by: economy features
ensure mythic-businesses   # Depends on: finance
ensure mythic-jobs         # Required by: job-specific resources
ensure mythic-labor        # Depends on: jobs, inventory

6. UI Resources

# User interface resources
ensure mythic-hud          # Main HUD
ensure mythic-menu         # Interaction menus
ensure mythic-targeting    # Entity targeting
ensure mythic-notifications
ensure mythic-chat
ensure mythic-phone
ensure mythic-laptop
UI resources can generally load in any order relative to each other, but should load after core systems.

7. Vehicle Systems

# Vehicle-related resources
ensure mythic-vehicles     # Core vehicle system
ensure mythic-fuel         # Depends on: vehicles
ensure mythic-customs      # Depends on: vehicles, inventory
ensure mythic-fitment      # Depends on: vehicles
ensure mythic-damage       # Depends on: vehicles
ensure mythic-dealerships  # Depends on: vehicles, finance

8. Job Resources

# Job-specific features
ensure mythic-police       # Depends on: jobs, inventory, vehicles
ensure mythic-ems          # Depends on: jobs, inventory
ensure mythic-mechanic     # Depends on: jobs, inventory, vehicles
ensure mythic-tow          # Depends on: jobs, vehicles
ensure mythic-taxi         # Depends on: jobs, vehicles
ensure mythic-restaurant   # Depends on: jobs, inventory, businesses

9. Property Systems

# Property and housing
ensure mythic-properties   # Depends on: finance, characters
ensure mythic-apartments   # Depends on: properties
ensure mythic-doors        # Access control system

10. Criminal Activities

# Criminal gameplay features
ensure mythic-robbery      # Depends on: police, inventory
ensure mythic-drugs        # Depends on: inventory, jobs
ensure mythic-weed         # Depends on: drugs, inventory
ensure mythic-casino       # Depends on: finance
ensure mythic-jail         # Depends on: police, characters

11. World Systems

# World enhancement resources
ensure mythic-locations    # Named locations
ensure mythic-blips        # Map blips
ensure mythic-polyzone     # Zone management
ensure mythic-ipl          # Interior loading
ensure mythic-objects      # Object spawning
ensure mythic-scenes       # Crime scenes

12. Utility Resources

# Utility and helper resources
ensure mythic-animations
ensure mythic-sounds
ensure mythic-visuals
ensure mythic-sync
ensure mythic-ped
ensure mythic-weapons
ensure mythic-status
ensure mythic-escort

13. Admin and Developer Tools (LAST)

# Admin and development tools - Load last
ensure mythic-admin
ensure mythic-commands
ensure mythic-keybinds
ensure mythic-dev-tools    # Only in development
Admin resources load last so they can access all components from other resources.

Complete Resource Load Order

# ====================================
# MYTHIC FRAMEWORK - RESOURCE LOADING
# ====================================

# === DATABASE (MUST BE FIRST) ===
ensure oxmysql

# === CORE FRAMEWORK ===
ensure mythic-base
ensure mythic-pwnzor

# === CONNECTION FLOW ===
ensure mythic-queue
ensure mythic-loadscreen

# === CHARACTER SYSTEM ===
ensure mythic-characters

# === CORE SYSTEMS ===
ensure mythic-inventory
ensure mythic-finance
ensure mythic-businesses
ensure mythic-jobs
ensure mythic-labor

# === UI RESOURCES ===
ensure mythic-hud
ensure mythic-menu
ensure mythic-targeting
ensure mythic-notifications
ensure mythic-chat
ensure mythic-phone
ensure mythic-laptop
ensure mythic-mdt
ensure mythic-radar

# === VEHICLE SYSTEMS ===
ensure mythic-vehicles
ensure mythic-fuel
ensure mythic-customs
ensure mythic-fitment
ensure mythic-damage
ensure mythic-dealerships

# === EMERGENCY SERVICES ===
ensure mythic-police
ensure mythic-ems
ensure mythic-dispatch

# === CIVILIAN JOBS ===
ensure mythic-mechanic
ensure mythic-tow
ensure mythic-taxi
ensure mythic-restaurant
ensure mythic-garbage
ensure mythic-hunting
ensure mythic-fishing
ensure mythic-mining
ensure mythic-logging

# === PROPERTY SYSTEMS ===
ensure mythic-properties
ensure mythic-apartments
ensure mythic-doors
ensure mythic-furniture

# === CRIMINAL ACTIVITIES ===
ensure mythic-robbery
ensure mythic-drugs
ensure mythic-weed
ensure mythic-meth
ensure mythic-casino
ensure mythic-racing
ensure mythic-jail

# === WORLD SYSTEMS ===
ensure mythic-locations
ensure mythic-blips
ensure mythic-polyzone
ensure mythic-ipl
ensure mythic-objects
ensure mythic-scenes
ensure mythic-weather

# === INTERACTION SYSTEMS ===
ensure mythic-animations
ensure mythic-sounds
ensure mythic-visuals
ensure mythic-sync
ensure mythic-ped
ensure mythic-weapons
ensure mythic-status
ensure mythic-needs
ensure mythic-escort
ensure mythic-emotes

# === COMMUNICATION ===
ensure mythic-radio
ensure mythic-voip

# === ADMIN & TOOLS (LOAD LAST) ===
ensure mythic-admin
ensure mythic-commands
ensure mythic-keybinds
ensure mythic-logs

# === DEVELOPMENT (DEV ONLY) ===
# Uncomment in development environment
# ensure mythic-dev-tools
# ensure mythic-debug

Dependency Relationships

Understanding which resources depend on which:
Everything depends on:
  • oxmysql - Database access
  • mythic-base - Core components (Logger, Database, Proxy, Callback, Middleware)
Most gameplay features depend on:
  • mythic-characters - Character data and management
Economy features depend on:
  • mythic-inventory - Item management
  • mythic-finance - Money and banking

Checking Resource Dependencies

Each resource declares its dependencies in fxmanifest.lua:
-- mythic-inventory/fxmanifest.lua
dependencies {
    'mythic-base',      -- Core framework required
    'mythic-characters' -- Character system required
}

-- Optional dependencies (works without, but enhanced with)
optional_dependencies {
    'mythic-phone'      -- Can send notifications to phone
}
FiveM will automatically wait for dependencies to load before starting the resource. If a dependency fails to load, the resource won’t start.

Manual Dependency Management

Resources can also manually wait for dependencies using RequestDependencies:
-- mythic-shops/server/component.lua
exports['mythic-base']:RequestDependencies('Shops', {
    'Inventory',
    'Finance',
    'Logger'
}, function(errors)
    if #errors > 0 then
        -- Dependencies failed to load
        print('[ERROR] Shops failed to load dependencies:', json.encode(errors))
        return
    end

    -- All dependencies loaded, safe to register component
    exports['mythic-base']:RegisterComponent('Shops', {
        -- Component methods here
    })
end)
This ensures components are available before use, even if fxmanifest dependencies are satisfied.

Resource Management Commands

Start/Stop/Restart Resources

# Start a resource
start mythic-inventory

# Stop a resource
stop mythic-inventory

# Restart a resource (stop + start)
restart mythic-inventory

# Ensure a resource (start if not running)
ensure mythic-inventory

# Refresh resource (reload files without restart)
refresh mythic-inventory
Restarting Core Resources: Restarting mythic-base or mythic-characters while server is live will likely crash dependent resources. Avoid unless necessary.

Check Resource Status

# List all resources and their status
status

# List only running resources
resmon

# Show resource information
# (Use in server console or F8 client console)

Adding Custom Resources

When adding your own resources to the framework:
1

Determine Dependencies

  • Does it need database access? → Depends on mythic-base
  • Does it need character data? → Depends on mythic-characters
  • Does it need inventory? → Depends on mythic-inventory
  • Does it need money? → Depends on mythic-finance
2

Add Dependencies to fxmanifest.lua

dependencies {
    'mythic-base',
    'mythic-characters',
    'mythic-inventory'
}
3

Add to resources.cfg

Place your resource after its dependencies:
ensure mythic-inventory  # Dependency
ensure my-custom-shop    # Your resource (after dependency)
4

Use RequestDependencies

exports['mythic-base']:RequestDependencies('MyShop', {
    'Inventory',
    'Finance'
}, function(errors)
    if #errors == 0 then
        -- Register your component
    end
end)

Troubleshooting Load Order Issues

Error: attempt to index field 'ComponentName' (a nil value)Cause: Trying to use a component before it’s registeredSolution:
  1. Check the resource that provides the component is loaded first
  2. Verify it’s in resources.cfg before the resource using it
  3. Use RequestDependencies to wait for component:
exports['mythic-base']:RequestDependencies('MyResource', {
    'MissingComponent'
}, function(errors)
    -- Component now available
end)
Error: Database connection not establishedCause: Resource trying to access database before oxmysql/mythic-base loadedSolution:
  • Ensure oxmysql is first in resources.cfg
  • Ensure mythic-base is second
  • Wait for Core:Shared:Ready event:
AddEventHandler('Core:Shared:Ready', function()
    -- Database now available
    COMPONENTS.Database:findOne(...)
end)
Error: Failed to start resource mythic-xyzCauses:
  • Dependency not loaded
  • Syntax error in resource
  • Missing files
Solutions:
  1. Check console for error messages
  2. Verify all dependencies in fxmanifest.lua are loaded
  3. Check resource files exist
  4. Look for Lua syntax errors
  5. Try refresh then ensure:
refresh mythic-xyz
ensure mythic-xyz
Error: Resources won’t load, waiting on each otherCause: Resource A depends on B, but B also depends on ASolution:
  • Restructure to remove circular dependency
  • Move shared functionality to a third resource
  • Use events instead of direct component calls
  • Delay initialization until both are loaded
Problem: Components work initially but fail after resource restartCause: Component registration not idempotent (doesn’t clean up old registrations)Solution:
  • Ensure RegisterComponent is called on every start
  • Don’t use persistent state in components without cleanup
  • Implement proper cleanup in onResourceStop:
AddEventHandler('onResourceStop', function(resourceName)
    if resourceName == GetCurrentResourceName() then
        -- Cleanup logic here
    end
end)

Best Practices

Document Dependencies

Always document what your resource depends on in:
  • README.md
  • fxmanifest.lua dependencies
  • Code comments

Fail Fast

Check for dependencies early and fail with clear error messages if missing:
if not COMPONENTS.Inventory then
    error('mythic-inventory required!')
end

Use RequestDependencies

Always use RequestDependencies for components you need:
RequestDependencies('MyResource', {
    'Database',
    'Logger',
    'Inventory'
}, callback)

Test Load Order

When adding resources:
  • Test on fresh server start
  • Test resource restart
  • Test with dependencies stopped
  • Verify error messages are clear

Minimize Dependencies

Only depend on what you actually need. Fewer dependencies = more flexible resource.

Version Dependencies

If you require specific versions, document it:
-- Requires mythic-base >= 2.0.0

Development vs Production

Different resource loading for different environments:
# resources.cfg with environment checks

# Core (always loaded)
ensure mythic-base
ensure mythic-characters

# Production resources
if [[ "${environment}" == "prod" ]]; then
    ensure mythic-anticheat-extra
    ensure mythic-monitoring
fi

# Development resources
if [[ "${environment}" == "dev" ]]; then
    ensure mythic-dev-tools
    ensure mythic-debug
    ensure mythic-test-framework
fi

Next Steps

Golden Rule: If you’re unsure about load order, put your resource last in resources.cfg. It’s safer to load after everything else than to load too early.