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)

Critical: oxmysql MUST be the first resource loaded. All other resources depend on database connectivity.

2. Core Framework

mythic-base contains the proxy system, logger, database wrapper, and all core components. Nothing works without it.

3. Queue and Loadscreen

These handle the connection flow before players enter the game.

4. Character System

Dependency Alert: Almost ALL gameplay resources depend on the Characters component. Load this before any gameplay features.

5. Core Systems

6. UI Resources

UI resources can generally load in any order relative to each other, but should load after core systems.

7. Vehicle Systems

8. Job Resources

9. Property Systems

10. Criminal Activities

11. World Systems

12. Utility Resources

13. Admin and Developer Tools (LAST)

Admin resources load last so they can access all components from other resources.

Complete Resource Load Order

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:
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:
This ensures components are available before use, even if fxmanifest dependencies are satisfied.

Resource Management Commands

Start/Stop/Restart Resources

Restarting Core Resources: Restarting mythic-base or mythic-characters while server is live will likely crash dependent resources. Avoid unless necessary.

Check Resource Status

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

3

Add to resources.cfg

Place your resource after its dependencies:
4

Use RequestDependencies

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:
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:
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:
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:

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:

Use RequestDependencies

Always use RequestDependencies for components you need:

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:

Development vs Production

To load different resources per environment, use separate server.cfg files or comment/uncomment lines:
Create separate server-dev.cfg and server-prod.cfg files and use the appropriate one when starting the server. FiveM’s server.cfg does not support conditional logic like if/else.

Next Steps

Component System

Understand how components work

Proxy Pattern

Learn dependency injection

Architecture

Framework architecture overview

Troubleshooting

Common issues and fixes
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.