From dae312a0add0103a43503c3d9cb211490fd509b0 Mon Sep 17 00:00:00 2001 From: Mycroft Date: Mon, 26 Apr 2021 23:17:56 +0100 Subject: [PATCH] Updates --- client/main.lua | 22 ++++-------------- config.lua | 61 +++++++++++++++++++++++++++++++++++++++++-------- server/main.lua | 34 ++++----------------------- 3 files changed, 62 insertions(+), 55 deletions(-) diff --git a/client/main.lua b/client/main.lua index 51f4246c..7e3ed50f 100644 --- a/client/main.lua +++ b/client/main.lua @@ -10,18 +10,6 @@ Citizen.CreateThread(function() Citizen.Wait(5000) - ESX.TriggerServerCallback('esx_shops:requestDBItems', function(ShopItems) - for k,v in pairs(ShopItems) do - if (Config.Zones[k] == nil) then - Config.Zones[k] = { - Items = {}, - Pos = {} - } - end - - Config.Zones[k].Items = v - end - end) end) function OpenShopMenu(zone) @@ -91,9 +79,9 @@ Citizen.CreateThread(function() for i = 1, #v.Pos, 1 do local blip = AddBlipForCoord(v.Pos[i]) - SetBlipSprite (blip, 52) - SetBlipScale (blip, 1.0) - SetBlipColour (blip, 2) + SetBlipSprite (blip, v.Type[i]) + SetBlipScale (blip, v.Size[i]) + SetBlipColour (blip, v.Color[i]) SetBlipAsShortRange(blip, true) BeginTextCommandSetBlipName('STRING') @@ -115,10 +103,10 @@ Citizen.CreateThread(function() local distance = #(playerCoords - v.Pos[i]) if distance < Config.DrawDistance then - DrawMarker(Config.Type, v.Pos[i], 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Config.Size.x, Config.Size.y, Config.Size.z, Config.Color.r, Config.Color.g, Config.Color.b, 100, false, true, 2, false, nil, nil, false) + DrawMarker(v.Type[i], v.Pos[i], 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, v.Size[i].x, v.Size[i].y, v.Size[i].z, v.Color[i].r, v.Color[i].g, v.Color[i].b, 100, false, true, 2, false, nil, nil, false) letSleep = false - if distance < Config.Size.x then + if distance < v.Size[i].x then isInMarker = true currentZone = k lastZone = k diff --git a/config.lua b/config.lua index f2b1f236..915b3d0b 100644 --- a/config.lua +++ b/config.lua @@ -1,14 +1,23 @@ Config = {} Config.DrawDistance = 100 -Config.Size = {x = 1.5, y = 1.5, z = 1.5} -Config.Color = {r = 0, g = 128, b = 255} -Config.Type = 1 Config.Locale = 'en' Config.Zones = { TwentyFourSeven = { - Items = {}, + Items = { + { + name = bread, + label = bread, + price = 100 + }, + { + name = water, + label = bread, + price = 100 + } + } + }, Pos = { vector3(373.8, 325.8, 102.5), vector3(2557.4, 382.2, 107.6), @@ -18,10 +27,25 @@ Config.Zones = { vector3(1961.4, 3740.6, 31.3), vector3(2678.9, 3280.6, 54.2), vector3(1729.2, 6414.1, 34.0) - }}, + }, + Size = {x = 1.0, y = 1.0, z = 1.0} + Type = 59, + Color = {r = 102, g = 102, b = 204, a = 255} +}, RobsLiquor = { - Items = {}, + Items = { + { + name = bread, + label = bread, + price = 100 + }, + { + name = water, + label = bread, + price = 100 + } + }, Pos = { vector3(1135.8, -982.2, 45.4), vector3(-1222.9, -906.9, 11.3), @@ -32,15 +56,34 @@ Config.Zones = { vector3(127.8, -1284.7, 28.2), --StripClub vector3(-1393.4, -606.6, 29.3), --Tequila la vector3(-559.9, 287.0, 81.1) --Bahamamas - }}, + }, + Size = 1.0, + Type = 59, + Color = {r = 102, g = 102, b = 204, a = 255} +}, LTDgasoline = { - Items = {}, + Items = { + { + name = bread, + label = bread, + price = 100 + }, + { + name = water, + label = bread, + price = 100 + } + }, Pos = { vector3(-48.5, -1757.5, 28.4), vector3(1163.3, -323.8, 68.2), vector3(-707.5, -914.2, 18.2), vector3(-1820.5, 792.5, 137.1), vector3(1698.3, 4924.4, 41.0) - }} + }, + Size = 1.0, + Type = 59, + Color = {r = 102, g = 102, b = 204, a = 255} +} } diff --git a/server/main.lua b/server/main.lua index 6b9a2bb5..d003b4a6 100644 --- a/server/main.lua +++ b/server/main.lua @@ -3,30 +3,6 @@ local ShopItems = {} TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) -MySQL.ready(function() - MySQL.Async.fetchAll('SELECT * FROM shops LEFT JOIN items ON items.name = shops.item', {}, function(shopResult) - for i=1, #shopResult, 1 do - if shopResult[i].name then - if ShopItems[shopResult[i].store] == nil then - ShopItems[shopResult[i].store] = {} - end - - table.insert(ShopItems[shopResult[i].store], { - label = shopResult[i].label, - item = shopResult[i].item, - price = shopResult[i].price, - }) - else - print(('esx_shops: invalid item "%s" found!'):format(shopResult[i].item)) - end - end - end) -end) - -ESX.RegisterServerCallback('esx_shops:requestDBItems', function(source, cb) - cb(ShopItems) -end) - RegisterServerEvent('esx_shops:buyItem') AddEventHandler('esx_shops:buyItem', function(itemName, amount, zone) local _source = source @@ -34,7 +10,6 @@ AddEventHandler('esx_shops:buyItem', function(itemName, amount, zone) amount = ESX.Math.Round(amount) - -- is the player trying to exploit? if amount < 0 then print('esx_shops: ' .. xPlayer.identifier .. ' attempted to exploit the shop!') return @@ -44,10 +19,11 @@ AddEventHandler('esx_shops:buyItem', function(itemName, amount, zone) local price = 0 local itemLabel = '' - for i=1, #ShopItems[zone], 1 do - if ShopItems[zone][i].item == itemName then - price = ShopItems[zone][i].price - itemLabel = ShopItems[zone][i].label + for i=1, #Config.Zones[zone].Items, 1 do + local item = Config.Zones[zone].Items[i] + if item.name == itemName then + price = item.price + itemLabel = item.label break end end