
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.
Database Setup
CoreX uses built-in MySQL support with a simple connection string configuration. No external MySQL resources required!
Installation
1. Download CoreX
# 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
:
# 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?"
3. Configure Discord
Set up your Discord bot and update the configuration in 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
# 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
mysql://username:password@host:port/database?
Configuration Structure
Module Configuration
Each module has its own configuration file in config/modules/
. Example:
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 keyidentifier
- Player licensename
- Player namemoney
- Cash amountbank
- Bank balancejob
- Current jobjob_grade
- Job gradeposition
- Last positioncreated_at
- Account creation datelast_login
- Last login timestamp
Characters Table
id
- Primary keyplayer_id
- Player referenceslot
- Character slot (1-5)name
- Character namegender
- Character genderdateofbirth
- Birth dateheight
- Character heightalive
- Alive statusposition
- Last position
Vehicles Table
id
- Primary keyowner
- Owner identifierplate
- License platevehicle
- Vehicle modelstored
- Garage statusgarage
- Garage locationfuel
- Fuel levelengine_health
- Engine conditionbody_health
- Body condition
Inventory Table
id
- Primary keyowner
- Owner identifiertype
- Inventory typeitem
- Item namecount
- Item quantitymetadata
- Item metadataslot
- 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)
benchmark
saveinv
Manually save all player inventories
saveinv
reload
Reload a specific module
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:
Admin Commands
These commands are available to administrators:
/kick [id] [reason]
Kick a player from the server
/kick 1 "Breaking rules"
/ban [id] [duration] [reason]
Ban a player from the server
/ban 1 24h "Cheating"
/unban [identifier]
Unban a player by their identifier
/unban license:123456789
/teleport [id]
Teleport to a player
/teleport 1
/bring [id]
Bring a player to you
/bring 1
/goto [id]
Go to a player
/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
-- 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
-- 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
-- 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:
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
-- 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
- Fork the repository
- Create a feature branch
- Make your changes following our coding standards
- Test your changes thoroughly
- 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
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