mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-09-01 18:58:54 +00:00
Added missing mysql indexes
This commit is contained in:
@@ -52,7 +52,7 @@ end)
|
||||
### License
|
||||
esx_addoninventory - inventories!
|
||||
|
||||
Copyright (C) 2015-2018 Jérémie N'gadi
|
||||
Copyright (C) 2015-2019 Jérémie N'gadi
|
||||
|
||||
This program Is free software: you can redistribute it And/Or modify it under the terms Of the GNU General Public License As published by the Free Software Foundation, either version 3 Of the License, Or (at your option) any later version.
|
||||
|
||||
|
||||
+11
-9
@@ -1,19 +1,21 @@
|
||||
USE `essentialmode`;
|
||||
|
||||
CREATE TABLE `addon_inventory` (
|
||||
`name` varchar(60) NOT NULL,
|
||||
`label` varchar(255) NOT NULL,
|
||||
`shared` int(11) NOT NULL,
|
||||
`name` VARCHAR(60) NOT NULL,
|
||||
`label` VARCHAR(100) NOT NULL,
|
||||
`shared` INT(11) NOT NULL,
|
||||
|
||||
PRIMARY KEY (`name`)
|
||||
);
|
||||
|
||||
CREATE TABLE `addon_inventory_items` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`inventory_name` varchar(255) NOT NULL,
|
||||
`name` varchar(255) NOT NULL,
|
||||
`count` int(11) NOT NULL,
|
||||
`owner` varchar(60) DEFAULT NULL,
|
||||
`id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`inventory_name` VARCHAR(255) NOT NULL,
|
||||
`name` VARCHAR(255) NOT NULL,
|
||||
`count` INT(11) NOT NULL,
|
||||
`owner` VARCHAR(60) DEFAULT NULL,
|
||||
|
||||
PRIMARY KEY (`id`)
|
||||
PRIMARY KEY (`id`),
|
||||
INDEX `index_addon_inventory_items_inventory_name_name` (`inventory_name`, `name`),
|
||||
INDEX `index_addon_inventory_items_inventory_name_name_owner` (`inventory_name`, `name`, `owner`)
|
||||
);
|
||||
@@ -63,15 +63,13 @@ function CreateAddonInventory(name, owner, items)
|
||||
|
||||
self.saveItem = function(name, count)
|
||||
if self.owner == nil then
|
||||
MySQL.Async.execute('UPDATE addon_inventory_items SET count = @count WHERE inventory_name = @inventory_name AND name = @item_name',
|
||||
{
|
||||
MySQL.Async.execute('UPDATE addon_inventory_items SET count = @count WHERE inventory_name = @inventory_name AND name = @item_name', {
|
||||
['@inventory_name'] = self.name,
|
||||
['@item_name'] = name,
|
||||
['@count'] = count
|
||||
})
|
||||
else
|
||||
MySQL.Async.execute('UPDATE addon_inventory_items SET count = @count WHERE inventory_name = @inventory_name AND name = @item_name AND owner = @owner',
|
||||
{
|
||||
MySQL.Async.execute('UPDATE addon_inventory_items SET count = @count WHERE inventory_name = @inventory_name AND name = @item_name AND owner = @owner', {
|
||||
['@inventory_name'] = self.name,
|
||||
['@item_name'] = name,
|
||||
['@count'] = count,
|
||||
|
||||
+4
-12
@@ -1,9 +1,5 @@
|
||||
ESX = nil
|
||||
Items = {}
|
||||
local InventoriesIndex = {}
|
||||
local Inventories = {}
|
||||
local SharedInventories = {}
|
||||
|
||||
local InventoriesIndex, Inventories, SharedInventories, Items = {}, {}, {}, {}
|
||||
ESX = nil
|
||||
|
||||
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
|
||||
|
||||
@@ -54,7 +50,6 @@ MySQL.ready(function()
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
local items = {}
|
||||
|
||||
for j=1, #result2, 1 do
|
||||
@@ -67,7 +62,6 @@ MySQL.ready(function()
|
||||
|
||||
local addonInventory = CreateAddonInventory(name, nil, items)
|
||||
SharedInventories[name] = addonInventory
|
||||
|
||||
end
|
||||
end
|
||||
end)
|
||||
@@ -92,15 +86,13 @@ AddEventHandler('esx_addoninventory:getSharedInventory', function(name, cb)
|
||||
cb(GetSharedInventory(name))
|
||||
end)
|
||||
|
||||
AddEventHandler('esx:playerLoaded', function(source)
|
||||
local _source = source
|
||||
local xPlayer = ESX.GetPlayerFromId(_source)
|
||||
AddEventHandler('esx:playerLoaded', function(playerId, xPlayer)
|
||||
local addonInventories = {}
|
||||
|
||||
for i=1, #InventoriesIndex, 1 do
|
||||
local name = InventoriesIndex[i]
|
||||
local inventory = GetInventory(name, xPlayer.identifier)
|
||||
|
||||
|
||||
if inventory == nil then
|
||||
inventory = CreateAddonInventory(name, xPlayer.identifier, {})
|
||||
table.insert(Inventories[name], inventory)
|
||||
|
||||
Reference in New Issue
Block a user