A modular, modern FiveM framework built in Lua, designed for flexibility, performance, and ease of use.

Modular Architecture

Dynamic module loading system with clean separation of concerns

Multi-Language Support

Built-in localization system supporting 5 languages

Discord Integration

Seamless Discord bot integration for permissions and chat

Multi-Character System

Support for multiple characters per player with perma-death

Built-in MySQL Support

Native MySQL integration with connection string configuration

Security First

Role-based permissions and comprehensive audit logging

Getting Started

CoreX is designed to be easy to set up and use. Follow these steps to get your server running with CoreX.

Prerequisites: FiveM Server, MySQL Database, Discord Bot Token

Database Setup

CoreX uses built-in MySQL support with a simple connection string configuration. No external MySQL resources required!

Installation

1. Download CoreX

Terminal
# Clone the repository
git clone https://github.com/Legacy-DEV-Team/CoreX.git

# Or download the latest release
# Extract to your FiveM resources folder

2. Configure Database

CoreX includes built-in MySQL support. Simply add your MySQL connection string to your server.cfg:

server.cfg
# MySQL Connection String
set mysql_connection "mysql://username:password@localhost:3306/database_name?"

# Example with specific values
set mysql_connection "mysql://root:mypassword@localhost:3306/corex_db?"
No External Dependencies: CoreX handles all MySQL operations internally using FiveM's native MySQL functions.

3. Configure Discord

Set up your Discord bot and update the configuration in config/permissions/discord.lua:

config/permissions/discord.lua
Config.Discord = {
    botToken = "your_bot_token",
    guildId = "your_guild_id",
    chatChannelId = "your_chat_channel_id",
    logsChannelId = "your_logs_channel_id"
}

4. Add to server.cfg

server.cfg
# Add CoreX to your server configuration
ensure CoreX

# MySQL connection string (if not already added)
set mysql_connection "mysql://username:password@localhost:3306/database_name?"

5. Start Your Server

Start your FiveM server and CoreX will automatically initialize all modules.

Configuration

CoreX uses a modular configuration system organized in the config/ folder.

Database Configuration

CoreX includes built-in MySQL support that automatically handles database operations. The framework will:

  • Auto-create tables: All required database tables are created automatically
  • Initialize data: Default jobs, items, and system data are set up
  • Handle connections: Connection pooling and error handling
  • Auto-save: Player data is automatically saved every 5 minutes
Connection String Format: mysql://username:password@host:port/database?

Configuration Structure

config/
modules/
jobs.lua
adminmenu.lua
inventory.lua
permissions/
discord.lua

Module Configuration

Each module has its own configuration file in config/modules/. Example:

config/modules/jobs.lua
Config.Jobs = {
    -- Job categories and permissions
    categories = {
        government = {
            name = "Government Jobs",
            roles = {"government", "admin"},
            jobs = {
                ems = {
                    name = "Emergency Medical Services",
                    grades = {
                        [0] = {name = "Trainee", salary = 1500},
                        [1] = {name = "Paramedic", salary = 2000},
                        [2] = {name = "Senior Paramedic", salary = 2500},
                        [3] = {name = "Chief", salary = 3000}
                    }
                }
            }
        }
    }
}

Database System

CoreX includes a comprehensive built-in MySQL database system powered by oxmysql for optimal performance and reliability.

oxmysql Integration

CoreX now uses oxmysql for enhanced database performance:

  • Optimized queries: Uses appropriate oxmysql exports (scalar, single, query, update, insert)
  • Transaction support: Atomic operations for data integrity
  • Performance monitoring: Built-in benchmark tools
  • Error handling: Robust connection and query error management
  • Connection pooling: Efficient database connection management

Database Schema

The framework automatically creates and manages the following tables:

Players Table

  • id - Primary key
  • identifier - Player license
  • name - Player name
  • money - Cash amount
  • bank - Bank balance
  • job - Current job
  • job_grade - Job grade
  • position - Last position
  • created_at - Account creation date
  • last_login - Last login timestamp

Characters Table

  • id - Primary key
  • player_id - Player reference
  • slot - Character slot (1-5)
  • name - Character name
  • gender - Character gender
  • dateofbirth - Birth date
  • height - Character height
  • alive - Alive status
  • position - Last position

Vehicles Table

  • id - Primary key
  • owner - Owner identifier
  • plate - License plate
  • vehicle - Vehicle model
  • stored - Garage status
  • garage - Garage location
  • fuel - Fuel level
  • engine_health - Engine condition
  • body_health - Body condition

Inventory Table

  • id - Primary key
  • owner - Owner identifier
  • type - Inventory type
  • item - Item name
  • count - Item quantity
  • metadata - Item metadata
  • slot - Inventory slot

Performance Features

  • Auto-save: Player data automatically saved every 5 minutes
  • Benchmarking: Built-in performance testing via core/server/benchmark.lua
  • Query optimization: Uses appropriate oxmysql exports for each operation type
  • Transaction support: ACID-compliant database operations
  • Error handling: Comprehensive error logging and recovery
  • Data validation: Input validation and sanitization
  • SQL injection prevention: Parameterized queries and input sanitization

Benchmarking

CoreX includes comprehensive database benchmarking tools:

  • Automatic testing: Runs on resource start after 5 seconds
  • Manual testing: Use console command benchmark
  • Performance metrics: Query timing and execution statistics
  • Test coverage: Tests all major database operations

Modules

CoreX comes with several built-in modules that provide essential functionality.

Multi-Character

Support for multiple characters per player with perma-death mechanics.

  • Up to 5 characters per player
  • Perma-death system
  • Character persistence
  • Slot management

Jobs

Comprehensive job system with Discord role integration.

  • Government jobs
  • Transport jobs
  • Civilian jobs
  • Illegal jobs

Inventory

Weight-based inventory system with drag & drop UI.

  • Item stacking
  • Weight limits
  • Drag & drop interface
  • Item persistence

Banking

Bank account management and transaction system.

  • Account management
  • Transaction logging
  • Transfer system
  • ATM integration

Vehicles

Vehicle garage, spawning, and ownership system.

  • Garage management
  • Vehicle persistence
  • Key sharing
  • Impound system

Admin Menu

Comprehensive admin tools with Discord logging.

  • Player management
  • Teleportation
  • Revive system
  • Discord logging

Commands & Keybindings

CoreX provides a comprehensive set of commands and keybindings for both players and administrators.

Console Commands

These commands are available in the server console:

benchmark

Run database performance benchmark (console only)

Usage: benchmark

saveinv

Manually save all player inventories

Usage: saveinv

reload

Reload a specific module

Usage: reload [module_name]

Player Commands

These commands are available to all players:

/help

Show available commands

/char

Open character selection menu

/job

Show current job information

/bank

Open banking interface

/inventory

Open inventory system

/vehicles

Show owned vehicles

/admin

Open admin panel (if authorized)

Keybindings

Default keybindings for quick access to features:

F1
Open main menu
F2
Open character menu
F3
Open job menu
F4
Open admin panel (if authorized)
F5
Open inventory
F6
Open banking
F7
Open vehicle management
ESC
Close menus

Admin Commands

These commands are available to administrators:

/kick [id] [reason]

Kick a player from the server

Usage: /kick 1 "Breaking rules"

/ban [id] [duration] [reason]

Ban a player from the server

Usage: /ban 1 24h "Cheating"

/unban [identifier]

Unban a player by their identifier

Usage: /unban license:123456789

/teleport [id]

Teleport to a player

Usage: /teleport 1

/bring [id]

Bring a player to you

Usage: /bring 1

/goto [id]

Go to a player

Usage: /goto 1

/noclip

Toggle noclip mode

/godmode

Toggle god mode

/invisible

Toggle invisibility

API Reference

CoreX provides a comprehensive API for developers to extend and integrate with the framework.

Core API

Player Management

Server-side
-- Get player data
local playerData = CoreX.Players.GetPlayerData(source)

-- Set player data
CoreX.Players.SetPlayerData(source, data)

-- Get player identifier
local identifier = CoreX.Players.GetPlayerIdentifier(source)

Database API

oxmysql Database Operations

Server-side
-- Single row query (optimized)
CoreX.Database.FetchSingle('SELECT * FROM players WHERE identifier = ?', {identifier}, function(result)
    if result then
        print(result.name)
    end
end)

-- Multiple rows query
CoreX.Database.FetchAll('SELECT * FROM players WHERE job = ?', {job}, function(results)
    for i, player in ipairs(results) do
        print(player.name)
    end
end)

-- Scalar value (COUNT, MAX, etc.)
CoreX.Database.FetchScalar('SELECT COUNT(*) FROM players', {}, function(count)
    print('Total players:', count)
end)

-- Insert with return ID
CoreX.Database.Insert('INSERT INTO players (identifier, name) VALUES (?, ?)', {identifier, name}, function(insertId)
    print('New player ID:', insertId)
end)

-- Update/Delete operations
CoreX.Database.Execute('UPDATE players SET money = ? WHERE identifier = ?', {money, identifier}, function(success)
    if success then
        print('Player money updated')
    end
end)

-- Transaction support
CoreX.Database.Transaction({
    {'UPDATE players SET money = money - ? WHERE id = ?', {amount, playerId}},
    {'UPDATE players SET money = money + ? WHERE id = ?', {amount, targetId}}
}, function(success)
    if success then
        print('Money transfer completed')
    end
end)

Localization API

Translation Functions

Shared
-- Get translation
local text = CoreX.Locale.Get("key", "en")

-- Get translation with parameters
local text = CoreX.Locale.Get("welcome", "en", {name = "John"})

-- Set language
CoreX.Locale.SetLanguage("en")

Localization

CoreX supports multiple languages with a fallback system.

Supported Languages

  • English (en) - Default language
  • Norwegian (no) - Norwegian translations
  • Spanish (es) - Spanish translations
  • French (fr) - French translations
  • German (de) - German translations

Adding Translations

To add a new language, create a locale file in the module's locale/ folder:

modules/jobs/locale/fr.lua
return {
    ["job_set"] = "Job défini sur %s",
    ["job_not_found"] = "Job non trouvé",
    ["no_permission"] = "Vous n'avez pas la permission",
    ["job_applied"] = "Candidature envoyée pour %s"
}

Security & Permissions

CoreX implements comprehensive security measures to protect your server.

Discord Integration

  • Role-based Access: All job access controlled by Discord roles
  • Server Entry: Players must have specific Discord roles to join
  • Admin Logging: All admin actions logged to Discord
  • Support Tickets: Ticket system with Discord thread creation

Permission System

Permission Check
-- Check if player has permission
if CoreX.Permissions.HasPermission(source, "admin.revive") then
    -- Allow action
end

-- Check Discord role
if CoreX.Discord.HasRole(source, "government") then
    -- Allow government job access
end

Contributing

We welcome contributions from the community! Please read our contributing guidelines.

How to Contribute

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes following our coding standards
  4. Test your changes thoroughly
  5. Submit a pull request

Coding Standards

  • Use camelCase for variables and functions
  • Use PascalCase for classes and modules
  • Use UPPER_CASE for constants
  • Add comments for complex logic
  • Follow the existing code style
Note: All technical documentation should be placed in the docs/ folder.

Changelog

View the complete changelog in the CHANGELOG.md file.

Latest Version: v1.0.2.0

  • oxmysql Integration: Replaced mysql-async with oxmysql for improved performance
  • Database Benchmarking: Built-in performance testing via core/server/benchmark.lua
  • Query Optimization: Uses appropriate oxmysql exports (scalar, single, query, update, insert)
  • Enhanced Error Handling: More robust error detection and reporting
  • Performance Monitoring: Built-in benchmarking capabilities
  • Updated Documentation: Comprehensive oxmysql integration documentation

Previous Version: v1.0.0.2

  • Built-in MySQL Support: Replaced external mysql-async dependency with native MySQL integration
  • Connection String Configuration: Simple mysql:// connection string format in server.cfg
  • Auto Table Creation: Framework automatically creates all required database tables
  • Enhanced Database API: New CoreX.Database namespace with transaction support
  • Improved Error Handling: Better database connection and query error management
  • Updated Documentation: Comprehensive database system documentation

Previous Version: v1.0.0.1

  • Cleaned up unused and deprecated files
  • Consolidated configuration structure
  • Created documentation site
  • Simplified root README