From 9cf5586d86b7e2d0305a5f9ae84ff6393532ba46 Mon Sep 17 00:00:00 2001 From: vecchiotom Date: Fri, 27 Apr 2018 21:10:51 +0200 Subject: [PATCH] I N D E N T --- server/main.lua | 102 ++++++++++++++++++++++++------------------------ 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/server/main.lua b/server/main.lua index 22d0fa21..36e8d7b1 100644 --- a/server/main.lua +++ b/server/main.lua @@ -5,85 +5,85 @@ TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) function LoadLicenses (source) TriggerEvent('esx_license:getLicenses', source, function (licenses) - TriggerClientEvent('esx_weashop:loadLicenses', source, licenses) + TriggerClientEvent('esx_weashop:loadLicenses', source, licenses) end) end if Config.EnableLicense == true then AddEventHandler('esx:playerLoaded', function (source) - LoadLicenses(source) + LoadLicenses(source) end) end function LoadShopItems(cb) - MySQL.Async.fetchAll('SELECT * FROM weashops', - {}, function(result) - local shopItems = {} - for i=1, #result, 1 do + 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 + 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) + 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 - local xPlayer = ESX.GetPlayerFromId(source) +local _source = source +local xPlayer = ESX.GetPlayerFromId(source) - if xPlayer.get('money') >= Config.LicensePrice then - xPlayer.removeMoney(Config.LicensePrice) +if xPlayer.get('money') >= Config.LicensePrice then + xPlayer.removeMoney(Config.LicensePrice) - TriggerEvent('esx_license:addLicense', _source, 'weapon', function () - LoadLicenses(_source) - end) - else - TriggerClientEvent('esx:showNotification', _source, _U('not_enough')) - end + TriggerEvent('esx_license:addLicense', _source, 'weapon', function () + LoadLicenses(_source) + end) +else + TriggerClientEvent('esx:showNotification', _source, _U('not_enough')) +end end) ESX.RegisterServerCallback('esx_weashop:requestDBItems', function(source, cb) - LoadShopItems(cb) +LoadShopItems(cb) end) RegisterServerEvent('esx_weashop:buyItem') AddEventHandler('esx_weashop:buyItem', function(itemName, price, zone) LoadShopItems(function(shopItems) - local _source = source - local xPlayer = ESX.GetPlayerFromId(source) - local account = xPlayer.getAccount('black_money') - if price == shopItems[itemName].price then - if zone=="BlackWeashop" then - if account.money >= price then - xPlayer.removeAccountMoney('black_money', price) - xPlayer.addWeapon(itemName, 42) - TriggerClientEvent('esx:showNotification', _source, _U('buy') .. ESX.GetWeaponLabel(itemName)) - else - TriggerClientEvent('esx:showNotification', _source, _U('not_enough_black')) - end - else - if xPlayer.get('money') >= price then - xPlayer.removeMoney(price) - xPlayer.addWeapon(itemName, 42) - TriggerClientEvent('esx:showNotification', _source, _U('buy') .. ESX.GetWeaponLabel(itemName)) - else - TriggerClientEvent('esx:showNotification', _source, _U('not_enough')) - end - end - end +local _source = source +local xPlayer = ESX.GetPlayerFromId(source) +local account = xPlayer.getAccount('black_money') +if price == shopItems[itemName].price then + if zone=="BlackWeashop" then + if account.money >= price then + xPlayer.removeAccountMoney('black_money', price) + xPlayer.addWeapon(itemName, 42) + TriggerClientEvent('esx:showNotification', _source, _U('buy') .. ESX.GetWeaponLabel(itemName)) + else + TriggerClientEvent('esx:showNotification', _source, _U('not_enough_black')) + end + else + if xPlayer.get('money') >= price then + xPlayer.removeMoney(price) + xPlayer.addWeapon(itemName, 42) + TriggerClientEvent('esx:showNotification', _source, _U('buy') .. ESX.GetWeaponLabel(itemName)) + else + TriggerClientEvent('esx:showNotification', _source, _U('not_enough')) + end + end +end end) - + end)