This seems to be conflicting with esx_status. I have tried searching but ca’t find a fix. During the character selection screen the esx_status bars are showing and when i actually select the character and spawn in the bars do not degrade until i restart esx_status. I have to restart this every time a user joins the server.
Running this, esx_status, esx_basicneeds, and esx_optionalneeds.
Any help would be appreciated. Thanks!
EDIT: I have figured this out. I missed a couple posts in here talking about it and also found the code that I needed to fix. If anyone else needs help with it just shoot me a PM.
I have an issue where after I make a character, it is saved, but does not display at the character select screen. The saved character is still assigned to the slot and I can choose it and login, its just not displayed as there? It still reads as create a new character. What am I missing?
Been looking for a fix, and cant seem to find it, I’ve found similar threads about it but no real solution, how do you fix it so when you die/respawn you spawn back into the character you made?
Duplicate Your esx_datastore or add This line on your esx_datastore server\main.lua
```-- Fix was taken from this link --
-- 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)
when loading characters it doesnt load unique skins, if i use another character it uses the same skin for all
i tried to load in Users - skin, but that didnt work
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?
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)