mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-09-01 18:58:54 +00:00
mysql-async v3.0.1 support
This commit is contained in:
+5
-17
@@ -7,8 +7,7 @@ local SharedInventories = {}
|
||||
|
||||
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
|
||||
|
||||
AddEventHandler('onMySQLReady', function()
|
||||
|
||||
MySQL.ready(function()
|
||||
local items = MySQL.Sync.fetchAll('SELECT * FROM items')
|
||||
|
||||
for i=1, #items, 1 do
|
||||
@@ -18,17 +17,13 @@ AddEventHandler('onMySQLReady', function()
|
||||
local result = MySQL.Sync.fetchAll('SELECT * FROM addon_inventory')
|
||||
|
||||
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_inventory_items WHERE inventory_name = @inventory_name',
|
||||
{
|
||||
['@inventory_name'] = name
|
||||
}
|
||||
)
|
||||
local result2 = MySQL.Sync.fetchAll('SELECT * FROM addon_inventory_items WHERE inventory_name = @inventory_name', {
|
||||
['@inventory_name'] = name
|
||||
})
|
||||
|
||||
if shared == 0 then
|
||||
|
||||
@@ -38,7 +33,6 @@ AddEventHandler('onMySQLReady', function()
|
||||
local items = {}
|
||||
|
||||
for j=1, #result2, 1 do
|
||||
|
||||
local itemName = result2[j].name
|
||||
local itemCount = result2[j].count
|
||||
local itemOwner = result2[j].owner
|
||||
@@ -52,7 +46,6 @@ AddEventHandler('onMySQLReady', function()
|
||||
count = itemCount,
|
||||
label = Items[itemName]
|
||||
})
|
||||
|
||||
end
|
||||
|
||||
for k,v in pairs(items) do
|
||||
@@ -76,9 +69,7 @@ AddEventHandler('onMySQLReady', function()
|
||||
SharedInventories[name] = addonInventory
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end)
|
||||
|
||||
function GetInventory(name, owner)
|
||||
@@ -103,11 +94,10 @@ end)
|
||||
|
||||
AddEventHandler('esx:playerLoaded', function(source)
|
||||
local _source = source
|
||||
local xPlayer = ESX.GetPlayerFromId(_source)
|
||||
local xPlayer = ESX.GetPlayerFromId(_source)
|
||||
local addonInventories = {}
|
||||
|
||||
for i=1, #InventoriesIndex, 1 do
|
||||
|
||||
local name = InventoriesIndex[i]
|
||||
local inventory = GetInventory(name, xPlayer.identifier)
|
||||
|
||||
@@ -117,9 +107,7 @@ AddEventHandler('esx:playerLoaded', function(source)
|
||||
end
|
||||
|
||||
table.insert(addonInventories, inventory)
|
||||
|
||||
end
|
||||
|
||||
xPlayer.set('addonInventories', addonInventories)
|
||||
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user