FixFX

Setup & Installation

Complete guide to setting up and installing ESX framework.

This guide covers the complete installation and initial setup of ESX framework for your FiveM server.

Prerequisites

Before installing ESX, ensure you have:

  • FiveM Server: A properly configured FiveM server
  • MySQL Database: MySQL 8.0+ or MariaDB 10.6+
  • Git: For cloning repositories
  • Basic Command Line Knowledge: Comfort with terminal commands

Installation Methods

ESX Legacy is the modern, updated version of ESX with improved performance and security.

1. Database Setup

Create a new MySQL database:

CREATE DATABASE esx_server CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'esx_user'@'localhost' IDENTIFIED BY 'your_secure_password';
GRANT ALL PRIVILEGES ON esx_server.* TO 'esx_user'@'localhost';
FLUSH PRIVILEGES;

2. Server Structure

Create the proper directory structure:

# Navigate to your server's resources folder
cd /path/to/your/server/resources
 
# Create ESX folder structure
mkdir -p [esx]
mkdir -p [standalone]

3. Core Framework Installation

# Clone ESX Legacy core
cd [esx]
git clone https://github.com/esx-framework/esx_core.git
git clone https://github.com/esx-framework/es_extended.git
 
# Essential resources
git clone https://github.com/esx-framework/esx_multicharacter.git
git clone https://github.com/esx-framework/esx_menu_default.git
git clone https://github.com/esx-framework/esx_menu_dialog.git
git clone https://github.com/esx-framework/esx_menu_list.git
git clone https://github.com/esx-framework/esx_notify.git
git clone https://github.com/esx-framework/esx_textui.git
git clone https://github.com/esx-framework/esx_context.git
 
# Basic gameplay resources
git clone https://github.com/esx-framework/esx_basicneeds.git
git clone https://github.com/esx-framework/esx_billing.git
git clone https://github.com/esx-framework/esx_society.git
git clone https://github.com/esx-framework/esx_datastore.git
git clone https://github.com/esx-framework/esx_addonaccount.git
git clone https://github.com/esx-framework/esx_addoninventory.git
 
# Jobs
git clone https://github.com/esx-framework/esx_ambulancejob.git
git clone https://github.com/esx-framework/esx_policejob.git
git clone https://github.com/esx-framework/esx_mechanicjob.git
 
# Properties and vehicles
git clone https://github.com/esx-framework/esx_property.git
git clone https://github.com/esx-framework/esx_vehicleshop.git
git clone https://github.com/esx-framework/esx_lscustom.git

4. Database Dependencies

Install required database resources:

# Navigate to standalone folder
cd ../[standalone]
 
# Clone database connector (choose one)
git clone https://github.com/overextended/oxmysql.git
# OR
git clone https://github.com/GHMatti/ghmattimysql.git mysql-async

5. Database Import

Import ESX database structure:

# Import base database
mysql -u esx_user -p esx_server < [esx]/es_extended/installation/esx_legacy.sql
 
# Import additional resource databases
mysql -u esx_user -p esx_server < [esx]/esx_society/installation/esx_society.sql
mysql -u esx_user -p esx_server < [esx]/esx_datastore/installation/esx_datastore.sql
mysql -u esx_user -p esx_server < [esx]/esx_addonaccount/installation/esx_addonaccount.sql
mysql -u esx_user -p esx_server < [esx]/esx_addoninventory/installation/esx_addoninventory.sql
mysql -u esx_user -p esx_server < [esx]/esx_billing/installation/esx_billing.sql
mysql -u esx_user -p esx_server < [esx]/esx_vehicleshop/installation/esx_vehicleshop.sql
mysql -u esx_user -p esx_server < [esx]/esx_lscustom/installation/esx_lscustom.sql
# Continue for other resources with database requirements

Method 2: ESX Template (Alternative)

For a quicker start, use the ESX server template:

# Clone the complete template
git clone https://github.com/esx-framework/esx-serverdumps.git
 
# This includes:
# - Pre-configured server structure
# - All essential resources
# - Database files
# - Basic configuration

Configuration

1. Database Connection

Configure your database connection in es_extended/config.lua:

Config = {}
Config.Locale = 'en'
 
Config.Accounts = {
    bank = _U('account_bank'),
    black_money = _U('account_black_money'),
    money = _U('account_money')
}
 
Config.StartingAccountMoney = {
    bank = 50000,
    black_money = 0,
    money = 5000
}
 
Config.StartingInventoryItems = false -- Set to false to disable
 
Config.DefaultSpawn = {x = -269.4, y = -955.3, z = 31.22, h = 205.8}
 
Config.EnablePlayerManagement = true
Config.EnableSocietyOwnedVehicles = false
Config.EnableLicenses = false
Config.EnableJailAccount = false
Config.EnablePVP = true
Config.MaxWeight = 24
Config.PaycheckInterval = 7 * 60000
Config.EnableDebug = false

2. Server.cfg Configuration

Add ESX resources to your server.cfg:

# Database
ensure oxmysql
# OR ensure mysql-async

# ESX Legacy Framework
ensure es_extended

# ESX Core Resources
ensure esx_menu_default
ensure esx_menu_dialog
ensure esx_menu_list
ensure esx_notify
ensure esx_textui
ensure esx_context

# ESX Base Resources
ensure esx_datastore
ensure esx_addonaccount
ensure esx_addoninventory
ensure esx_society
ensure esx_billing

# Character System
ensure esx_multicharacter

# Basic Needs
ensure esx_basicneeds

# Jobs
ensure esx_policejob
ensure esx_ambulancejob
ensure esx_mechanicjob

# Vehicles & Properties
ensure esx_vehicleshop
ensure esx_lscustom
ensure esx_property

# Database connection string
set mysql_connection_string "mysql://esx_user:your_secure_password@localhost/esx_server?charset=utf8mb4"

# Server configuration
set sv_hostname "My ESX Server"
set sv_maxclients 32
set server_description "An ESX FiveM Server"

# ESX specific
set es_enableCustomData 1
set esx_multicharacter_enabled true

# Licensing
sv_licenseKey "your_license_key_here"

3. Resource Loading Order

Proper loading order is crucial for ESX:

# 1. Database connector
ensure oxmysql

# 2. Core framework
ensure es_extended

# 3. Menu systems
ensure esx_menu_default
ensure esx_menu_dialog
ensure esx_menu_list

# 4. UI Systems
ensure esx_notify
ensure esx_textui
ensure esx_context

# 5. Base systems
ensure esx_datastore
ensure esx_addonaccount
ensure esx_addoninventory
ensure esx_society

# 6. Character system
ensure esx_multicharacter

# 7. Core gameplay
ensure esx_basicneeds
ensure esx_billing

# 8. Jobs
ensure esx_policejob
ensure esx_ambulancejob
ensure esx_mechanicjob

# 9. Vehicles & Properties
ensure esx_vehicleshop
ensure esx_lscustom
ensure esx_property

# 10. Custom resources (add your custom resources last)

Verification & Testing

1. Server Startup

Start your server and verify ESX loads properly:

# Check the console for errors
# Look for messages like:
# [es_extended] ESX Started!
# [esx_multicharacter] Multicharacter Started!

2. Database Verification

Check that database tables were created:

USE esx_server;
SHOW TABLES;
 
-- You should see tables like:
-- users
-- vehicles
-- user_accounts
-- jobs
-- job_grades
-- etc.

3. In-Game Testing

  1. Connect to Server: Join your server
  2. Character Creation: Test the multicharacter system
  3. Basic Functions: Try commands like /me, /job, /money
  4. Job System: Test changing jobs with /setjob [job] [grade]

Common Installation Issues

Database Connection Errors

Error: Failed to execute query: Access denied

Solution:

-- Recreate user with proper permissions
DROP USER 'esx_user'@'localhost';
CREATE USER 'esx_user'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON esx_server.* TO 'esx_user'@'localhost';
FLUSH PRIVILEGES;

Resource Loading Errors

Error: Resource [es_extended] couldn't be started

Solutions:

  1. Check resource path: Ensure resources are in [esx] folder
  2. Verify manifest: Check fxmanifest.lua syntax
  3. Dependencies: Ensure database connector loads before es_extended

Shared Object Errors

Error: ESX object is nil

Solution:

-- Use proper ESX initialization
ESX = exports['es_extended']:getSharedObject()
 
-- Alternative (legacy method)
ESX = nil
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)

Post-Installation Steps

1. Admin Setup

Add yourself as admin:

-- Method 1: Direct database
INSERT INTO users (identifier, name, accounts, job, job_grade, group) 
VALUES ('license:your_license_here', 'Your Name', '{"bank":25000,"black_money":0,"money":5000}', 'admin', 0, 'admin');
 
-- Method 2: In-game command (if you have permissions)
/setjob admin 0

2. Basic Server Configuration

Configure basic server settings:

-- In es_extended/config.lua
Config.DefaultSpawn = {x = -269.4, y = -955.3, z = 31.22, h = 205.8} -- Customize spawn location
Config.StartingAccountMoney = {bank = 10000, black_money = 0, money = 1000} -- Starting money
Config.PaycheckInterval = 7 * 60000 -- Paycheck every 7 minutes

3. Job Configuration

Add or modify jobs in the database:

-- Add custom job
INSERT INTO jobs (name, label) VALUES ('taxi', 'Taxi Driver');
 
-- Add job grades
INSERT INTO job_grades (job_name, grade, name, label, salary, skin_male, skin_female) 
VALUES ('taxi', 0, 'driver', 'Driver', 200, '{}', '{}');
 
INSERT INTO job_grades (job_name, grade, name, label, salary, skin_male, skin_female) 
VALUES ('taxi', 1, 'experienced', 'Experienced Driver', 300, '{}', '{}');

4. Society Configuration

Set up societies for jobs:

-- Create society for job
INSERT INTO addon_account (name, label, shared) 
VALUES ('society_taxi', 'Taxi Company', 1);
 
INSERT INTO datastore (name, label, shared) 
VALUES ('society_taxi', 'Taxi Company', 1);
 
INSERT INTO addon_inventory (name, label, shared) 
VALUES ('society_taxi', 'Taxi Company', 1);

ESX vs ESX Legacy

ESX Legacy Advantages

  • Better Performance: Optimized code and reduced resource usage
  • Security Improvements: Better protection against exploits
  • Modern Code: Updated to use newer FiveM features
  • Active Development: Regular updates and bug fixes
  • Compatibility: Better compatibility with modern resources

Migration from Old ESX

If migrating from old ESX to ESX Legacy:

  1. Backup Everything: Database and server files
  2. Update Resources: Replace old ESX resources with Legacy versions
  3. Database Migration: Run migration scripts if provided
  4. Test Thoroughly: Verify all functionality works

Next Steps

After successful installation:

  1. ESX Development - Learn about ESX development
  2. ESX Troubleshooting - Common issues and solutions
  3. Resource Management - Managing and updating ESX resources

Congratulations! You now have a working ESX server. Take time to familiarize yourself with the framework before adding custom resources.

Always backup your database and server files before making major changes or updates.