[RELEASE][ESX] KASHacters Multi Character

At first it was working fine, now when people load in they can no longer can make more then 1 person it just loads the first person they made… How can I fix this? Also new people are spawning random when it was in legion the first day I tested this.

Multi Char is working fine, great job, btw. BUT i’m encountering a bug? When i store something in my apartment, then log out and back in to a DIFFERENT character, he shares the same apartment inventory. Got any idea why?

wondering if there is a way to lock slots. So having two slots open for regular people and 3-4 for admins

Cool idea i guess… butttt WHY? why limit people to only 2 characters?

Okay so ive done every step etc when someone connects to try to make someone this is what console pushes

SCRIPT ERROR: @esx_identity/server.lua:23: attempt to index a nil value (field ‘?’)

ref (@esx_identity/server.lua:23)
setImmediate (@mysql-async/mysql-async.js:5039)
SCRIPT ERROR: @es_extended/server/main.lua:162: attempt to index a nil value (field ‘?’)
ref (@es_extended/server/main.lua:162)
setImmediate (@mysql-async/mysql-async.js:5039)
Sending heartbeat to live-internal.fivem.net:30110
Connecting: Snolizz
Sending heartbeat to live-internal.fivem.net:30110
Uncaught TypeError: Cannot convert undefined or null to object
@mysql-async/mysql-async.js(5083,49): pool.query
@mysql-async/mysql-async.js(1094,10):
@mysql-async/mysql-async.js(1060,16):
@mysql-async/mysql-async.js(275,24): Sequence.end
@mysql-async/mysql-async.js(2216,8): Query._handleFinalResultPacket
@mysql-async/mysql-async.js(2200,8): Query.EofPacket
@mysql-async/mysql-async.js(6197,23): Protocol._parsePacket
@mysql-async/mysql-async.js(6458,12): write
@mysql-async/mysql-async.js(5957,16): Protocol.write
@mysql-async/mysql-async.js(683,28):

TypeError: Cannot convert undefined or null to object

when i load in if I do /register though it works however it doesnt save anything when you leave and come back.

Duplicate Your esx_datastore or add This line on your esx_datastore server\main.lua

-- https://forum.cfx.re/t/release-esx-kashacters-multi-character/251613/448?u=xxfri3ndlyxx --
AddEventHandler('esx:playerLoaded', function(source)

  local result = MySQL.Sync.fetchAll('SELECT * FROM datastore')

	for i=1, #result, 1 do
		local name   = result[i].name
		local label  = result[i].label
		local shared = result[i].shared

		local result2 = MySQL.Sync.fetchAll('SELECT * FROM datastore_data WHERE name = @name', {
			['@name'] = name
		})

		if shared == 0 then

			table.insert(DataStoresIndex, name)
			DataStores[name] = {}

			for j=1, #result2, 1 do
				local storeName  = result2[j].name
				local storeOwner = result2[j].owner
				local storeData  = (result2[j].data == nil and {} or json.decode(result2[j].data))
				local dataStore  = CreateDataStore(storeName, storeOwner, storeData)

				table.insert(DataStores[name], dataStore)
			end
		end
	end

	local _source = source
	local xPlayer = ESX.GetPlayerFromId(_source)
  	local dataStores = {}
  
	for i=1, #DataStoresIndex, 1 do
		local name      = DataStoresIndex[i]
		local dataStore = GetDataStore(name, xPlayer.identifier)

		if dataStore == nil then
			MySQL.Async.execute('INSERT INTO datastore_data (name, owner, data) VALUES (@name, @owner, @data)',
			{
				['@name']  = name,
				['@owner'] = xPlayer.identifier,
				['@data']  = '{}'
			})

			dataStore = CreateDataStore(name, xPlayer.identifier, {})
			table.insert(DataStores[name], dataStore)
		end

		table.insert(dataStores, dataStore)
	end

	xPlayer.set('dataStores', dataStores)
end)

hi,

HAve you any issue ?

Best regards

Currently having an issue where I am the only one able to view the character slot screen. All other users get a blank screen. Suggestions?

Having a slight issue.

When I add more table identifiers, the character selection just doesn’t appear.

local IdentifierTables = {
    {table = "users", column = "identifier"},
    {table = "user_accounts", column = "identifier"},
    {table = "rented_vehicles", column = "owner"},
}

But because of the lack of table identifiers, all characters made by the same steam have the same licenses/vehicles/inventories.

Only recently realised this was happening so it’s been abused on the server for a while.

Any help would be appreciated.

– fixed it, but it’s managed to mess up esx_properties… onto the next project.

Does anyone know why when i spawn in i will spawn in at the coords 0 0 0?

anyone have a fix with the new update ? where this script wont work

image

Don’t understand the issue with this please help

With this am i replacing the current

AddEventHandler('esx:playerLoaded', function(playerId, xPlayer)

Or just adding it to the bottom of the resource? :slight_smile: thanks

When you were adding the table identifiers, how were you able to distinguish which query was a “identifier” and which one was an “owner” I want to set up my tables but I don’t know which is which or when to use “identifier” or “owner”

To get your identifier. Do this query in your database

SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME = 'owner'

and

SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME = 'indentifier'

Credit @Xnubil for this query line

Hey man, thank you so much for the quick reply! :slight_smile: I will do that now!

I am having a similar issue where if I add any tables, the character screen does not pop up. I have checked the database for spelling and accuracy and I still cant quite put my finger on what causes that. The moment I remove what I added to the server/main.lua, It will start working again but It wont save anything. Any help would be awesome! and if i figure it out, Ill note what the fix was for people having the same problem

local IdentifierTables = {
    {table = "owned_vehicles", column = "owner"},
	{table = "addon_account_data", column = "owner"},
    {table = "addon_inventory_items", column = "owner"},
    {table = "datastore_data", column = "owner"},
	{table = "owned_properties", column = "owner"},
    {table = "phone_calls", column = "owner"},
    {table = "phone_messages", column = "owner"},
	{table = "rented_vehicles", column = "owner"},
    {table = "user_licenses", column = "owner"},
    {table = "user_accounts", column = "identifier"},
	{table = "users", column = "identifier"},
	{table = "billing", column = "identifier"},
	{table = "characters", column = "identifier"},
	{table = "jail", column = "identifier"},
	{table = "phone_users_contacts", column = "identifier"},
	{table = "playersTattoos", column = "identifier"},
	{table = "society_moneywash", column = "identifier"},
	{table = "user_inventory", column = "identifier"},
	{table = "user_parkings", column = "identifier"},
}

Here is my database too


Thank you!
** EDIT ** (literally 5 minutes later)
commenting out the phone_ tables seemed to fix it. Any idea what that might mean?

I took out datastore, I didn’t even put the phone in.

It feels like there’s a different fix for each person :sweat_smile:

1 Like

Does anyone still get duplicate entry issues with this, even AFTER using the datastore fix?

[31m[ERROR] [MySQL] [esx_datastore] An error happens on MySQL for query "INSERT INTO datastore_data (name, owner, data) VALUES ('property', 'steam:', '{}')": ER_DUP_ENTRY: Duplicate entry 'property-steam:' for key 'index_datastore_data_name_owner'[0m
[31m[ERROR] [MySQL] [esx_datastore] An error happens on MySQL for query "INSERT INTO datastore_data (name, owner, data) VALUES ('user_ears', 'steam:', '{}')": ER_DUP_ENTRY: Duplicate entry 'user_ears-steam:' for key 'index_datastore_data_name_owner'[0m
[31m[ERROR] [MySQL] [esx_datastore] An error happens on MySQL for query "INSERT INTO datastore_data (name, owner, data) VALUES ('user_glasses', 'steam:', '{}')": ER_DUP_ENTRY: Duplicate entry 'user_glasses-steam:' for key 'index_datastore_data_name_owner'[0m
[31m[ERROR] [MySQL] [esx_datastore] An error happens on MySQL for query "INSERT INTO datastore_data (name, owner, data) VALUES ('user_mask', 'steam:', '{}')": ER_DUP_ENTRY: Duplicate entry 'user_mask-steam:' for key 'index_datastore_data_name_owner'[0m
[31m[ERROR] [MySQL] [esx_datastore] An error happens on MySQL for query "INSERT INTO datastore_data (name, owner, data) VALUES ('user_helmet', 'steam:', '{}')": ER_DUP_ENTRY: Duplicate entry 'user_helmet-steam:' for key 'index_datastore_data_name_owner'[0m

When you did the fix, you need to remove the current

AddEventHandler('esx:playerLoaded', function(playerId, xPlayer)

And replcae that hole function with the fix :slight_smile:

1 Like