mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-09-02 14:01:19 +00:00
mysql-async v3.0.1 support
This commit is contained in:
+1
-12
@@ -5,12 +5,10 @@ local SharedAccounts = {}
|
||||
|
||||
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
|
||||
|
||||
AddEventHandler('onMySQLReady', function ()
|
||||
|
||||
MySQL.ready(function()
|
||||
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
|
||||
@@ -22,7 +20,6 @@ AddEventHandler('onMySQLReady', function ()
|
||||
if shared == 0 then
|
||||
|
||||
table.insert(AccountsIndex, name)
|
||||
|
||||
Accounts[name] = {}
|
||||
|
||||
for j=1, #result2, 1 do
|
||||
@@ -35,7 +32,6 @@ AddEventHandler('onMySQLReady', function ()
|
||||
local money = nil
|
||||
|
||||
if #result2 == 0 then
|
||||
|
||||
MySQL.Sync.execute('INSERT INTO addon_account_data (account_name, money, owner) VALUES (@account_name, @money, NULL)',
|
||||
{
|
||||
['@account_name'] = name,
|
||||
@@ -43,7 +39,6 @@ AddEventHandler('onMySQLReady', function ()
|
||||
})
|
||||
|
||||
money = 0
|
||||
|
||||
else
|
||||
money = result2[1].money
|
||||
end
|
||||
@@ -52,9 +47,7 @@ AddEventHandler('onMySQLReady', function ()
|
||||
SharedAccounts[name] = addonAccount
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end)
|
||||
|
||||
function GetAccount(name, owner)
|
||||
@@ -83,12 +76,10 @@ AddEventHandler('esx:playerLoaded', function(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,
|
||||
@@ -101,9 +92,7 @@ AddEventHandler('esx:playerLoaded', function(source)
|
||||
end
|
||||
|
||||
table.insert(addonAccounts, account)
|
||||
|
||||
end
|
||||
|
||||
xPlayer.set('addonAccounts', addonAccounts)
|
||||
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user