From dae312a0add0103a43503c3d9cb211490fd509b0 Mon Sep 17 00:00:00 2001 From: Mycroft Date: Mon, 26 Apr 2021 23:17:56 +0100 Subject: [PATCH 1/7] 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 From 4a10412d9bab942d1efafdf74345a38df8b49673 Mon Sep 17 00:00:00 2001 From: Mycroft Date: Mon, 26 Apr 2021 23:20:04 +0100 Subject: [PATCH 2/7] Update config.lua --- config.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.lua b/config.lua index 915b3d0b..d19d599a 100644 --- a/config.lua +++ b/config.lua @@ -85,5 +85,5 @@ Config.Zones = { Size = 1.0, Type = 59, Color = {r = 102, g = 102, b = 204, a = 255} -} +}, } From 78c8139a8b072e838fcf75cd920d97b1ea28babf Mon Sep 17 00:00:00 2001 From: Mycroft Date: Mon, 26 Apr 2021 23:21:26 +0100 Subject: [PATCH 3/7] Update config.lua --- config.lua | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/config.lua b/config.lua index d19d599a..ff3dfb33 100644 --- a/config.lua +++ b/config.lua @@ -16,7 +16,6 @@ Config.Zones = { label = bread, price = 100 } - } }, Pos = { vector3(373.8, 325.8, 102.5), @@ -28,7 +27,7 @@ Config.Zones = { vector3(2678.9, 3280.6, 54.2), vector3(1729.2, 6414.1, 34.0) }, - Size = {x = 1.0, y = 1.0, z = 1.0} + Size = {x = 1.0, y = 1.0, z = 1.0}, Type = 59, Color = {r = 102, g = 102, b = 204, a = 255} }, @@ -85,5 +84,5 @@ Config.Zones = { Size = 1.0, Type = 59, Color = {r = 102, g = 102, b = 204, a = 255} -}, +} } From 390ee49f73028e82fee2cdc609f88f8775c9f375 Mon Sep 17 00:00:00 2001 From: Mycroft Date: Mon, 26 Apr 2021 23:33:29 +0100 Subject: [PATCH 4/7] fixes --- client/main.lua | 4 ++-- config.lua | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/client/main.lua b/client/main.lua index 7e3ed50f..579b3469 100644 --- a/client/main.lua +++ b/client/main.lua @@ -103,10 +103,10 @@ Citizen.CreateThread(function() local distance = #(playerCoords - v.Pos[i]) if distance < Config.DrawDistance then - 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) + DrawMarker(Config.MarkerType, v.Pos[i], 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Config.MarkerSize.x, Config.MarkerSize.y, Config.MarkerSize.z, Config.MarkerColor.r, Config.MarkerColor.g, Config.MarkerColor.b, 100, false, true, 2, false, nil, nil, false) letSleep = false - if distance < v.Size[i].x then + if distance < Config.MarkerSize.x then isInMarker = true currentZone = k lastZone = k diff --git a/config.lua b/config.lua index ff3dfb33..c69fd272 100644 --- a/config.lua +++ b/config.lua @@ -1,5 +1,8 @@ Config = {} Config.DrawDistance = 100 +Config.MarkerSize = {x = 1.1, y = 1.1, z = 0.9} +Config.MarkerType = 21 +Config.MarkerColor = {r = 102, g = 102, b = 204, a = 255} Config.Locale = 'en' Config.Zones = { @@ -27,7 +30,7 @@ Config.Zones = { vector3(2678.9, 3280.6, 54.2), vector3(1729.2, 6414.1, 34.0) }, - Size = {x = 1.0, y = 1.0, z = 1.0}, + Size = 1.0, Type = 59, Color = {r = 102, g = 102, b = 204, a = 255} }, From af2a25767bcc288dd5bc54b2eb223af1f7e7e6a0 Mon Sep 17 00:00:00 2001 From: Mycroft Date: Mon, 26 Apr 2021 23:50:47 +0100 Subject: [PATCH 5/7] fixes --- client/main.lua | 8 ++++---- config.lua | 30 +++++++++++++++--------------- esx_shops.sql | 19 ------------------- 3 files changed, 19 insertions(+), 38 deletions(-) delete mode 100644 esx_shops.sql diff --git a/client/main.lua b/client/main.lua index 579b3469..049a35eb 100644 --- a/client/main.lua +++ b/client/main.lua @@ -20,7 +20,7 @@ function OpenShopMenu(zone) table.insert(elements, { label = ('%s - %s'):format(item.label, _U('shop_item', ESX.Math.GroupDigits(item.price))), itemLabel = item.label, - item = item.item, + item = item.name, price = item.price, -- menu properties @@ -79,9 +79,9 @@ Citizen.CreateThread(function() for i = 1, #v.Pos, 1 do local blip = AddBlipForCoord(v.Pos[i]) - SetBlipSprite (blip, v.Type[i]) - SetBlipScale (blip, v.Size[i]) - SetBlipColour (blip, v.Color[i]) + SetBlipSprite (blip, v.Type) + SetBlipScale (blip, v.Size) + SetBlipColour (blip, v.Color) SetBlipAsShortRange(blip, true) BeginTextCommandSetBlipName('STRING') diff --git a/config.lua b/config.lua index c69fd272..4ae11565 100644 --- a/config.lua +++ b/config.lua @@ -10,13 +10,13 @@ Config.Zones = { TwentyFourSeven = { Items = { { - name = bread, - label = bread, + name = "bread", + label = "bread", price = 100 }, { - name = water, - label = bread, + name = "water", + label = "water", price = 100 } }, @@ -32,19 +32,19 @@ Config.Zones = { }, Size = 1.0, Type = 59, - Color = {r = 102, g = 102, b = 204, a = 255} + Color = 25 }, RobsLiquor = { Items = { { - name = bread, - label = bread, + name = "bread", + label = "bread", price = 100 }, { - name = water, - label = bread, + name = "water", + label = "water", price = 100 } }, @@ -61,19 +61,19 @@ Config.Zones = { }, Size = 1.0, Type = 59, - Color = {r = 102, g = 102, b = 204, a = 255} + Color = 25 }, LTDgasoline = { Items = { { - name = bread, - label = bread, + name = "bread", + label = "bread", price = 100 }, { - name = water, - label = bread, + name = "water", + label = "water", price = 100 } }, @@ -86,6 +86,6 @@ Config.Zones = { }, Size = 1.0, Type = 59, - Color = {r = 102, g = 102, b = 204, a = 255} + Color = 25 } } diff --git a/esx_shops.sql b/esx_shops.sql deleted file mode 100644 index e60fdd04..00000000 --- a/esx_shops.sql +++ /dev/null @@ -1,19 +0,0 @@ -USE `es_extended`; - -CREATE TABLE `shops` ( - `id` int NOT NULL AUTO_INCREMENT, - `store` varchar(100) NOT NULL, - `item` varchar(100) NOT NULL, - `price` int NOT NULL, - - PRIMARY KEY (`id`) -); - -INSERT INTO `shops` (store, item, price) VALUES - ('TwentyFourSeven','bread',30), - ('TwentyFourSeven','water',15), - ('RobsLiquor','bread',30), - ('RobsLiquor','water',15), - ('LTDgasoline','bread',30), - ('LTDgasoline','water',15) -; From 7156d50da3c272e2e8a7db3c2c5220f0143dc20e Mon Sep 17 00:00:00 2001 From: Mycroft Date: Mon, 26 Apr 2021 23:55:51 +0100 Subject: [PATCH 6/7] Add Config --- client/main.lua | 2 ++ config.lua | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/client/main.lua b/client/main.lua index 049a35eb..46a56488 100644 --- a/client/main.lua +++ b/client/main.lua @@ -77,6 +77,7 @@ end) Citizen.CreateThread(function() for k,v in pairs(Config.Zones) do for i = 1, #v.Pos, 1 do + if v.Show then local blip = AddBlipForCoord(v.Pos[i]) SetBlipSprite (blip, v.Type) @@ -89,6 +90,7 @@ Citizen.CreateThread(function() EndTextCommandSetBlipName(blip) end end + end end) -- Enter / Exit marker events diff --git a/config.lua b/config.lua index 4ae11565..5c7a0b5f 100644 --- a/config.lua +++ b/config.lua @@ -32,7 +32,8 @@ Config.Zones = { }, Size = 1.0, Type = 59, - Color = 25 + Color = 25, + Show = true -- show blip }, RobsLiquor = { @@ -61,7 +62,8 @@ Config.Zones = { }, Size = 1.0, Type = 59, - Color = 25 + Color = 25, + Show = true -- show blip }, LTDgasoline = { @@ -86,6 +88,7 @@ Config.Zones = { }, Size = 1.0, Type = 59, - Color = 25 + Color = 25, + Show = true -- show blip } } From 7a19d5c0ee3ffc6a3558a567b60d37f8287ace96 Mon Sep 17 00:00:00 2001 From: Mycroft Date: Tue, 27 Apr 2021 00:12:42 +0100 Subject: [PATCH 7/7] ShowBlip Config --- client/main.lua | 6 ++++-- config.lua | 9 ++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/client/main.lua b/client/main.lua index 46a56488..64b2c98e 100644 --- a/client/main.lua +++ b/client/main.lua @@ -77,7 +77,7 @@ end) Citizen.CreateThread(function() for k,v in pairs(Config.Zones) do for i = 1, #v.Pos, 1 do - if v.Show then + if v.ShowBlip then local blip = AddBlipForCoord(v.Pos[i]) SetBlipSprite (blip, v.Type) @@ -105,10 +105,12 @@ Citizen.CreateThread(function() local distance = #(playerCoords - v.Pos[i]) if distance < Config.DrawDistance then + if v.ShowMarker then DrawMarker(Config.MarkerType, v.Pos[i], 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Config.MarkerSize.x, Config.MarkerSize.y, Config.MarkerSize.z, Config.MarkerColor.r, Config.MarkerColor.g, Config.MarkerColor.b, 100, false, true, 2, false, nil, nil, false) + end letSleep = false - if distance < Config.MarkerSize.x then + if distance < 2.0 then isInMarker = true currentZone = k lastZone = k diff --git a/config.lua b/config.lua index 5c7a0b5f..58047091 100644 --- a/config.lua +++ b/config.lua @@ -33,7 +33,8 @@ Config.Zones = { Size = 1.0, Type = 59, Color = 25, - Show = true -- show blip + ShowBlip = true, + ShowMarker = true }, RobsLiquor = { @@ -63,7 +64,8 @@ Config.Zones = { Size = 1.0, Type = 59, Color = 25, - Show = true -- show blip + ShowBlip = true, + ShowMarker = true }, LTDgasoline = { @@ -89,6 +91,7 @@ Config.Zones = { Size = 1.0, Type = 59, Color = 25, - Show = true -- show blip + ShowBlip = true, + ShowMarker = true } }