Skip to main content
The mythic-base resource is the foundation of Mythic Framework, providing the component proxy system, logging, database access, and essential utilities that all other resources depend on.

Core Exports

These are the four fundamental exports that power the entire framework:

RegisterComponent

Register a new component or override existing

FetchComponent

Retrieve a registered component

ExtendComponent

Add methods to existing component

RequestDependencies

Asynchronously wait for dependencies

RegisterComponent

Register a new component or override an existing protected component.

Syntax

Parameters

string
required
Name of the component to register (e.g., ‘Inventory’, ‘Jobs’, ‘MyComponent’)
table
required
Table containing component methods and propertiesSpecial Properties:
  • _protected (boolean) - If true, component cannot be overridden
  • _required (table) - Array of method names that must exist
  • _name (string) - Internal name for logging

Returns

boolean
Returns true if component was registered successfully

Examples

Basic Component:
Protected Component with Required Methods:
Component with State:

Notes

Component Naming: Use PascalCase for component names (e.g., ‘Inventory’, ‘VehicleManager’, ‘MyFeature’)
Protected Components: Attempting to override a protected component will fail with an error. Use ExtendComponent to add methods to protected components.

FetchComponent

Retrieve a registered component for use.

Syntax

Parameters

string
required
Name of the component to fetch

Returns

table|nil
The component table if found, nil if not registered

Examples

Basic Fetch:
Using COMPONENTS Global:
Fetch Multiple Components:

Notes

COMPONENTS Global: After Core:Shared:Ready event, all components are available in the COMPONENTS global table. Use ComponentName instead of repeatedly calling FetchComponent.
Timing: Don’t fetch components at the top level of your script! They may not be registered yet. Wait for Core:Shared:Ready or use RequestDependencies.

ExtendComponent

Add new methods to an existing component without overriding it.

Syntax

Parameters

string
required
Name of the component to extend
table
required
Table containing new methods to add to the component

Returns

boolean
Returns true if extension was successful

Examples

Add Helper Methods:
Override Method While Preserving Original:
Add Integration Methods:

Notes

Non-Destructive: ExtendComponent adds methods without removing existing ones. If a method name already exists on the component, it will be overridden with the new implementation.
Protected Components: ExtendComponent cannot extend components that have _protected = true. Attempting to do so will fail with a warning: "Attempt To Extend Protected Component". Core components like Database and Logger are protected.
Modular Extensions: Use ExtendComponent to add resource-specific functionality to non-protected components without modifying the original resource.

RequestDependencies

Asynchronously wait for component dependencies to be registered before initializing your component.

Syntax

Parameters

string
required
Name of your component (for error reporting)
table
required
Array of component names that must be loaded before callback executes
function
required
Function called when all dependencies are loaded or on timeoutCallback Parameters:
  • errors (table) - Array of error messages (empty if all dependencies loaded)

Returns

Nothing (callback-based)

Examples

Basic Dependency Management:
Multiple Dependencies:
Graceful Degradation:

Notes

Always Use RequestDependencies: Even if dependencies are in fxmanifest.lua, use RequestDependencies to ensure components are registered before you use them.
Timeout: Dependencies have a timeout (default 30 seconds). If a dependency doesn’t load in time, it will error in the callback.
Load Order: Resources still need proper load order in resources.cfg. RequestDependencies handles component registration timing, not resource loading.

Core:Shared:Ready Event

The Core:Shared:Ready event fires when mythic-base has finished initializing and all core components are available.

Syntax

When to Use

Use Core:Shared:Ready when you need to:
  • Access core components (Logger, Database, etc.)
  • Set up event handlers that use components
  • Initialize features that depend on the framework

Examples

Client-Side Initialization:
Server-Side Initialization:

COMPONENTS Global

The COMPONENTS global table contains all registered components for easy access.

Usage

Available After

COMPONENTS is populated after the Core:Shared:Ready event fires.

Common Components


Best Practices

❌ Bad:
✅ Good:
❌ Bad:
✅ Good:
When to use _protected = true:
  • Core framework components
  • Components with complex internal state
  • Components where overriding would break other resources
When NOT to use:
  • Simple utility components
  • Components designed to be customizable
  • Resource-specific components

Next Steps

Proxy Pattern

Deep dive into the proxy system

Component System

Learn component architecture

Logger API

Logging component reference

Database API

Database component reference

Creating Resources

Build your first component