anyone have a fix with the new update ? where this script wont work
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? 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! 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
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
So datastore now works fine, I tried the same fix with addon account as that spits pretty much the same error, But yeah this code wotn work or it? Have i missed something here?
AddEventHandler('esx:playerLoaded', function(source)
local result = MySQL.Sync.fetchAll('SELECT * FROM addon_account')
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 addon_account_data WHERE account_name = @account_name', {
['@account_name'] = name
})
if shared == 0 then
table.insert(AccountsIndex, name)
Accounts[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 addonAccounts = CreateAddonAccount(storeName, storeOwner, storeData)
table.insert(Accounts[name], account)
end
end
end
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
local addonAccounts = {}
for i=1, #AccountsIndex, 1 do
local name = AccountsIndex[i]
local account = GetAccount(name, xPlayer.identifier)
if account == nil then
MySQL.Async.execute('INSERT INTO addon_account_data (account_name, money, owner) VALUES (@account_name, @money, @owner)', {
['@account_name'] = name,
['@money'] = 0,
['@owner'] = xPlayer.identifier
})
account = CreateAddonAccount(name, xPlayer.identifier, {})
table.insert(Accounts[name], account)
end
table.insert(addonAccounts, account)
end
xPlayer.set('addonAccounts', addonAccounts)
end)
So did someone fixed issue with [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
?
Ahaha, I feel so dumb. Thanks friend
i have it all the time and its still doing it…
When you did the fix, you need to remove the current
AddEventHandler('esx:playerLoaded', function(playerId, xPlayer)
yeah
Thanks very much. I will try it
Bit of a late reply, had some shit to deal with IRL. So this resource is made to work with ESX Standard not with other ESX Resources, I can’t tell which server is using what resources.
Sorry that I wasn’t able to help a lot of you and thanks everyone who helped eachother out in this thread. I hope you guys still enjoy this resource.