Multicharacter

Step-by-step installation guide, common issues & solutions, code snippets, error codes, config previews, locales previews, SQL previews, and changelogs; all in 1 easily accessible place.

Buy Here

FiveM Forums Post

YouTube Showcase Video

This resource can be purchased as part of a bundle for a discount here.

Translate

INSTALLATION GUIDE

Step 0 - First Steps

Step 1 - Fxmanifest

Step 2 - Configure Resource

Step 3 - SQL Database

Step 4 - Install Dependencies

Resource Name
Download
Details

cd_drawtextui

REQUIRED by default for the switch character locations if enabled but can be replaced/removed.

Step 5 - ESX Client Edit

We need to do a small modification to stop your framework from registering our character instantly when you load into the server.

essentialmode/client/main.lua/line 5 - comment out this code.

View the Example here.

Step 6 - Player Skin Edit

We will be setting the skin of your chosen character directly from the cd_multicharacter or cd_identity, so we don't need your skin creator script to do this.

Part 1: Find the block of code that looks similar to the examples below in the client-side main.lua and comment out the code.

There are many different versions and not all will look the exact same.

View the examples below:

Example 1

Example 2

Step 7 - Multi-Peds Skin Edit

Now we need to copy and paste some code into your character skin creation script to set the skin of the peds. Currently, we support 3 different clothing scripts. However, we have 2 different methods for esx_skin as the first supports older versions and the second supports newer versions, but always try the older version first.

If you use esx_skin, use this version first.

Part 1 - Copy and paste this export below into your skinchanger script, anywhere in the client-side main.lua.

Part 2 - Copy and paste this block of code below into your skinchanger script, at the very bottom of the client-side main.lua.

OPTIONAL FEATURES

This section is to help you understand how the built-in features of this resource work, and if applicable, how you can make them compatible with other resources. These features are not required, they are optional and can be configured in the [configs/config.lua].

Advanced multi-character method

This is completely optional. We do not recommend using this option unless you have basic knowledge of Lua and you understand what needs to be done from reading the instructions below. This method is more complicated and more effort to install but is far more optimized than the standard esx_kashacters method.

Part 1: Set the Config.UseAdvancedMultiCharMethod in the config.lua to true.

Part 2: If you are switching from the standard multi-character version to the advanced multicharacter version you need to use this command in your server console below before any players join.

Part 3: Replace the FiveM native method of getting a players identifier (steam id, license) GetPlayerIdentifiers(source)[1] or GetPlayerIdentifiers(source)[2] with xPlayer.identifier for every server-side resource which uses the identifier to fetch a character's data from the database. xPlayer of course needs to be defined before using it eg., local xPlayer = ESX.GetPlayerFromId(source).

Example 1: Do not change this.

Example 2: Change this.

Part 4: Follow the guide below for your version of ESX.

essentialmode/server/main.lua/line 41 - replace the existing block of code with this.

View the Before and After examples here.

Switching Characters

Part 1: Copy and paste this block of code below into your character skin creator script, at the very bottom of the client-side main.lua.

Part 2: We need to add 2 events to your es_extended resource to tell the code that we are switching characters.

ESX (all versions) - /server/main.lua - add this block of code at the bottom of the file.

INFORMATION

Default Key Binds

These keys can be modified and/or disabled in the Keys and Commands section of the [configs/config.lua].

Key

Description

Enter / Left Mouse

Select a character.

Left / Right Arrows

Cycle through the characters.

Chat Commands

These chat commands can be renamed and/or disabled in the Keys and Commands section of the [configs/config.lua].

The exact usage for each command will be displayed in the chat suggestions when using the commands in-game.

Command

Description

/charslots

(staff command) To check/add/remove a player's character slots.

/switchcharacter

If enabled, this will allow players to change characters in-game.

/DatabaseCleaner

(console command) This will remove all of the unneeded rows in your database which ESX resources unnecessarily add. Should only be needed a couple of times per month.

/SetAllMaxChars

(console command) This will set the max character slots for all player's in the database - if you ever need to change them all.

/AdvancedMultichar

(console command) Read here before using.

COMMON ISSUES

Please check out our Troubleshooting Guide before contacting our support.

🔔 Folder Name Make sure the name of the folder is cd_multicharacter.

🔔 Encrypted Files Do not edit the encrypted files in any way.

🔔 Always F8 Quit Make sure you and your players fully close FiveM before reconnecting to your server by either F8 quitting or force closing FiveM; this is a known issue with FiveM, not the multicharacter.

🔔 Always Restart Server Never restart the resource while the server is live; always restart the server to ensure no unforeseen issues.

SERVER-SIDE (database)

SQL Unknown Column Error?

eg., if you see an SQL error in the server console similar to this example - ER_BAD_FIELD_ERROR: Unknown colum 'max_chars' in 'where clause'.

SQL Table Doesn't Exist Error?

eg., if you see an SQL error in the server console similar to this example - ER_NO_SUCH_TABLE: Table 'exampletable' dosesn't exist'.

SQL Duplicate Entry Error? (datastore table)

eg., if you see an SQL error saying you have a duplicate entry in the datastore table similar to this: [ERROR] [MySQL] An error happens on MySQL for query "INSERT INTO datastore_data (name, owner, data) VALUES ('property', 'steam:111738473874', '{}')": ER_DUP_ENTRY: Duplicate entry 'property-steam:111738473874' for key 'index_datastore_data_name_owner'.

SERVER-SIDE

Characters not saving after re-logging?

eg., if your characters don't save after you create them or some data is not being saved in the database.

All of my characters are default peds with no character info?

eg., if you see default peds with no character information being display when you are certain you have characters saved in the database.

UI not displaying the correct sex?

eg., if you see "Non-Binary" on the character selection UI, this means the script could not find one of the standard sex types eg., m, male, f, female in the sex column for this character in the users database table. And if you see "Autosexual" that means the sex column for one of your characters is empty.

CLIENT-SIDE

Ped visible on first spawn?

eg., if you see your ped when first loading into the server before the character selection screen activates.

Ped in front of camera?

eg., if you see your player's ped standing in front of the camera during the character selection screen.

No such export GetPedList in resource skinchanger?

eg., if you see an error similar to this in the client F8 console.

Character floating in the sky

eg., if your character is floating in the sky (like this).

Issues with skins not loading?

eg., if your peds skins are not loading.

Characters not showing but blue arrows do show

eg., if your character is not showing but the blue arrows are showing.

ERROR CODES

If you see an error code not listed below please open a script support ticket in the Codesign Discord.

665 - This is because you have copied and pasted the Config.DatabaseTables from an old version or from esx_kashacters. Use the table format from the default config and add to it.

634 - There is an error in the GetSkin() function in the configs/client_customise_me.lua. Please try to troubleshoot this yourself before contacting support.

778 - The sex column for one of your characters in the users database table is empty. It should contain m, male, f, female etc., in a string format. This means your identity script is not adding the correct data to the database so you should check why. But a quick fix is to manually add m into the database column which is currently empty.

897/654 - The GetIdentifier function in the server_customise_me.lua is returning a nil value, when it should be returning the player's identifier as a string. This is because the string inside the Config.ESX_version is invalid. Only one of the following options is acceptable: [ '1.1' / '1.2' / '1.final' / 'exm' / 'legacy' ], or because the Config.Identifiertype has a typo in it.

331/487/905 - The GetUserInfos function in the server_customise_me.lua is not returning a table. This is most likely due to an issue in the database. You can try removing the characters for the player(s) having the issue and tell them to relog. But you still need to debug this yourself.

FRESH TEST SERVER

PLEASE READ: The only purpose of the steps below is to help you debug the multicharacter script if you are having issues that are not common andunable to debug the cause of the issues.

We recommend you do this on a test server/local host.

Test Environment Setup

Guide

Step 1 - Download Server Files

Download our full FiveM Server folder from our GitHub.

Do you use esx_skin? Download this version.

Do you use cui_character? Download this version.

Step 2 - Add License Key

Open the server.cfg and add in your licenseKey.

Step 3 - Import Database

Watch this video if you are unsure how to do this.

Step 4 - Add Codesign Scripts

Make sure you download the latest versions of cd_multicharacter / cd_spawnselect / cd_identity and add them into the [Codesign] folder.

Now start the server, create a character, relog and choose your newly created character.

CHANGELOG

Files Changed

Not every update requires you to replace the whole folder. We do this because we understand it's a pain to redo the configs for every update.

  • All Files - This means you should delete your old cd_multicharacter folder, download and add in the latest version, reconfigure the configs folder and restart your server.

  • All Files Except config.lua - This means you should do all of the above (in the All Files section) but additionally make a backup of the config.lua file and replace the new config.lua file with the one you made a backup of.

  • Specific Files - This means you can copy and paste the SPECIFIC new files over the old ones and restart the server.

Update Type

On rare occasions, you are forced to update to the latest version. Mostly due to authentication updates where the old versions will no longer work.

  • Mandatory - This means you MUST update to this new version, or the old versions will no longer work.

  • Optional - This means it's completely your choice whether you wish to update to the latest version. But we do not offer support for old versions for obvious reasons; they are old.

26/12/2020 - 10/08/2021

v3.0.0 - v3.2.0

Files Changed:

Update Type:

Changelog:

Edit

  • Made modifications for this to work out of the box with "cd_identity".

  • Changed "Database cleaner" to be a command instead of being used every restart as its only really needed to be used once every week to a month.

  • Modified the "Config.DatabaseTables" to be easier to understand for new people.

  • Updated the codesign error handlers.

  • Updated the SetAllMaxChars console command to also update the max_chars column default value in the user_lastcharacter database table with the new value.

  • Added some extra fail-safe checks to ensure stability - If a player's maximum character limit in the user_lastcharacter database table is larger than the maximum amount of ped coordinates that the script is currently configured for, the script will fix itself and show the default 5 characters as a temporary fix until the server devs can resolve the issue.

  • Added checks so the spawnmanager exports are only triggered for certain versions of esx.

  • Fixed compatibility with linden_inventory.

  • When you change the Config.DefaultCharAmount it will automatically modify the default maximum character value in the database.

  • All of your Config.DatabaseTables identifier column lengths are automatically checked and set to the minimum value of 50 if needed.

  • All of the code required to add compatibility with other clothing/skin resources is now available to edit.

  • Your chosen characters skin data is now sent to the CharacterHasLoaded_EXISTING function in order to reduce SQL queries.

  • Removed some config options which ask you if you are using other Codesign resources and replaced them the GetResourceState() FiveM native to ensure people don't misconfigure the config which would cause script breaking problems.

  • Moved the code to change the location of the peds to the config to be more ”new developer friendly“.

  • Removed some unneeded config options and rewrote the config to be more "new developer friendly".

  • Removed some unneeded SQL queries along with greatly optimising others such as the get character data quiey and the get skin queries.

  • Rewrote huge portions of the server and the client side code to be more optimized.

Last updated

Was this helpful?