mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-31 10:18:54 +00:00
code clean up
This commit is contained in:
+27
-39
@@ -15,6 +15,26 @@ if Config.EnableLicense == true then
|
||||
end)
|
||||
end
|
||||
|
||||
function LoadShopItems(cb)
|
||||
MySQL.Async.fetchAll('SELECT * FROM weashops',
|
||||
{}, function(result)
|
||||
local shopItems = {}
|
||||
for i=1, #result, 1 do
|
||||
|
||||
if shopItems[result[i].name] == nil then
|
||||
shopItems[result[i].name] = {}
|
||||
end
|
||||
|
||||
table.insert(shopItems[result[i].name], {
|
||||
name = result[i].item,
|
||||
price = result[i].price,
|
||||
label = ESX.GetWeaponLabel(result[i].item)
|
||||
})
|
||||
cb(shopItems)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
RegisterServerEvent('esx_weashop:buyLicense')
|
||||
AddEventHandler('esx_weashop:buyLicense', function ()
|
||||
local _source = source
|
||||
@@ -32,49 +52,14 @@ AddEventHandler('esx_weashop:buyLicense', function ()
|
||||
end)
|
||||
|
||||
ESX.RegisterServerCallback('esx_weashop:requestDBItems', function(source, cb)
|
||||
MySQL.Async.fetchAll('SELECT * FROM weashops',
|
||||
{}, function(result)
|
||||
local shopItems = {}
|
||||
for i=1, #result, 1 do
|
||||
|
||||
if shopItems[result[i].name] == nil then
|
||||
shopItems[result[i].name] = {}
|
||||
end
|
||||
|
||||
table.insert(shopItems[result[i].name], {
|
||||
name = result[i].item,
|
||||
price = result[i].price,
|
||||
label = ESX.GetWeaponLabel(result[i].item)
|
||||
})
|
||||
|
||||
end
|
||||
|
||||
cb(shopItems)
|
||||
|
||||
end
|
||||
)
|
||||
LoadShopItems(cb)
|
||||
end)
|
||||
|
||||
RegisterServerEvent('esx_weashop:buyItem')
|
||||
AddEventHandler('esx_weashop:buyItem', function(itemName, price, zone)
|
||||
MySQL.Async.fetchAll('SELECT * FROM weashops',
|
||||
{}, function(result)
|
||||
local shopItems = {}
|
||||
for i=1, #result, 1 do
|
||||
LoadShopItems(function(shopItems)
|
||||
|
||||
if shopItems[result[i].name] == nil then
|
||||
shopItems[result[i].name] = {}
|
||||
end
|
||||
|
||||
table.insert(shopItems[result[i].name], {
|
||||
name = result[i].item,
|
||||
price = result[i].price,
|
||||
label = ESX.GetWeaponLabel(result[i].item)
|
||||
})
|
||||
|
||||
end
|
||||
|
||||
local _source = source
|
||||
local _source = source
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
local account = xPlayer.getAccount('black_money')
|
||||
if price == shopItems[itemName].price then
|
||||
@@ -97,5 +82,8 @@ AddEventHandler('esx_weashop:buyItem', function(itemName, price, zone)
|
||||
end
|
||||
end
|
||||
|
||||
end)
|
||||
end)
|
||||
|
||||
|
||||
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user