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 inconfigs/resources.cfg:
1. Database Layer (FIRST)
2. Core Framework
mythic-base contains the proxy system, logger, database wrapper, and all core components. Nothing works without it.
3. Queue and Loadscreen
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
7. Vehicle Systems
8. Job Resources
9. Property Systems
10. Criminal Activities
11. World Systems
12. Utility Resources
13. Admin and Developer Tools (LAST)
Complete Resource Load Order
View Complete resources.cfg
View Complete resources.cfg
Dependency Relationships
Understanding which resources depend on which:- Core Dependencies
- Vehicle Dependencies
- Job Dependencies
- Property Dependencies
- Criminal Dependencies
Everything depends on:
oxmysql- Database accessmythic-base- Core components (Logger, Database, Proxy, Callback, Middleware)
mythic-characters- Character data and management
mythic-inventory- Item managementmythic-finance- Money and banking
Checking Resource Dependencies
Each resource declares its dependencies infxmanifest.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 usingRequestDependencies:
Resource Management Commands
Start/Stop/Restart Resources
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
Component Not Found Error
Component Not Found Error
Error:
attempt to index field 'ComponentName' (a nil value)Cause: Trying to use a component before it’s registeredSolution:- Check the resource that provides the component is loaded first
- Verify it’s in
resources.cfgbefore the resource using it - Use
RequestDependenciesto wait for component:
Database Connection Failed
Database Connection Failed
Error:
Database connection not establishedCause: Resource trying to access database before oxmysql/mythic-base loadedSolution:- Ensure
oxmysqlis first in resources.cfg - Ensure
mythic-baseis second - Wait for
Core:Shared:Readyevent:
Resource Won't Start
Resource Won't Start
Error:
Failed to start resource mythic-xyzCauses:- Dependency not loaded
- Syntax error in resource
- Missing files
- Check console for error messages
- Verify all dependencies in fxmanifest.lua are loaded
- Check resource files exist
- Look for Lua syntax errors
- Try
refreshthenensure:
Circular Dependency
Circular Dependency
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
Random Component Errors After Restart
Random Component Errors After Restart
Problem: Components work initially but fail after resource restartCause: Component registration not idempotent (doesn’t clean up old registrations)Solution:
- Ensure
RegisterComponentis 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 separateserver.cfg files or comment/uncomment lines:
Next Steps
Component System
Understand how components work
Proxy Pattern
Learn dependency injection
Architecture
Framework architecture overview
Troubleshooting
Common issues and fixes