refactor: ESX Shops - ReadMe, TextUI, better blips and markers!

This commit is contained in:
Mycroft
2022-07-16 16:36:31 +01:00
parent 12dfcced05
commit fc00c4e1ca
4 changed files with 22 additions and 43 deletions
+5 -28
View File
@@ -1,33 +1,10 @@
# esx_shops <h1 align='center'>[ESX] Shops</a></h1><p align='center'><b><a href='https://discord.esx-framework.org/'>Discord</a> - <a href='https://esx-framework.org/'>Website</a> - <a href='https://docs.esx-framework.org/legacy/installation'>Documentation</a></b></h5>
## Download & Installation This Resource allows Players to shop til they Drop! You Configure *everything* within the Config.lua, and dont worry about those pesky cheaters, we have Security Steve on the door to protect you and your city!
### Using [fvm](https://github.com/qlaffont/fvm-installer)
```
fvm install --save --folder=esx esx-org/esx_shops
```
### Using Git
```
cd resources
git clone https://github.com/ESX-Org/esx_shops [esx]/esx_shops
```
### Manually
- Download https://github.com/ESX-Org/esx_shops/archive/master.zip
- Put it in the `[esx]` directory
## Installation
- Import `esx_shops.sql` to your database
- Add this in your `server.cfg`:
```
start esx_shops
```
# Legal # Legal
### License
esx_shops - shoppin' esx_shops - shop til you drop!
Copyright (C) 2015-2022 Jérémie N'gadi Copyright (C) 2015-2022 Jérémie N'gadi
@@ -35,4 +12,4 @@ This program Is free software: you can redistribute it And/Or modify it under th
This program Is distributed In the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty Of MERCHANTABILITY Or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License For more details. This program Is distributed In the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty Of MERCHANTABILITY Or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License For more details.
You should have received a copy Of the GNU General Public License along with this program. If Not, see http://www.gnu.org/licenses/. You should have received a copy Of the GNU General Public License along with this program. If Not, see <http://www.gnu.org/licenses/>.
+7 -5
View File
@@ -24,12 +24,12 @@ function OpenShopMenu(zone)
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'shop', { ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'shop', {
title = _U('shop'), title = _U('shop'),
align = 'bottom-right', align = 'bottom-left',
elements = elements elements = elements
}, function(data, menu) }, function(data, menu)
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'shop_confirm', { ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'shop_confirm', {
title = _U('shop_confirm', data.current.value, data.current.itemLabel, ESX.Math.GroupDigits(data.current.price * data.current.value)), title = _U('shop_confirm', data.current.value, data.current.itemLabel, ESX.Math.GroupDigits(data.current.price * data.current.value)),
align = 'bottom-right', align = 'bottom-left',
elements = { elements = {
{label = _U('no'), value = 'no'}, {label = _U('no'), value = 'no'},
{label = _U('yes'), value = 'yes'} {label = _U('yes'), value = 'yes'}
@@ -89,16 +89,16 @@ CreateThread(function()
if currentAction then if currentAction then
Sleep = 0 Sleep = 0
ESX.ShowHelpNotification(currentActionMsg)
if IsControlJustReleased(0, 38) and currentAction == 'shop_menu' then if IsControlJustReleased(0, 38) and currentAction == 'shop_menu' then
currentAction = nil currentAction = nil
ESX.HideUI()
OpenShopMenu(currentActionData.zone) OpenShopMenu(currentActionData.zone)
end end
end end
local playerCoords = GetEntityCoords(PlayerPedId()) local playerCoords = GetEntityCoords(PlayerPedId())
local isInMarker, currentZone = false local isInMarker, currentZone = false, nil
for k,v in pairs(Config.Zones) do for k,v in pairs(Config.Zones) do
for i = 1, #v.Pos, 1 do for i = 1, #v.Pos, 1 do
@@ -107,7 +107,7 @@ CreateThread(function()
if distance < Config.DrawDistance then if distance < Config.DrawDistance then
Sleep = 0 Sleep = 0
if v.ShowMarker 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) 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 end
if distance < 2.0 then if distance < 2.0 then
isInMarker = true isInMarker = true
@@ -120,11 +120,13 @@ CreateThread(function()
if isInMarker and not hasAlreadyEnteredMarker then if isInMarker and not hasAlreadyEnteredMarker then
hasAlreadyEnteredMarker = true hasAlreadyEnteredMarker = true
ESX.TextUI(currentActionMsg)
TriggerEvent('esx_shops:hasEnteredMarker', currentZone) TriggerEvent('esx_shops:hasEnteredMarker', currentZone)
end end
if not isInMarker and hasAlreadyEnteredMarker then if not isInMarker and hasAlreadyEnteredMarker then
hasAlreadyEnteredMarker = false hasAlreadyEnteredMarker = false
ESX.HideUI()
TriggerEvent('esx_shops:hasExitedMarker', lastZone) TriggerEvent('esx_shops:hasExitedMarker', lastZone)
end end
Wait(Sleep) Wait(Sleep)
+6 -6
View File
@@ -1,8 +1,8 @@
Config = {} Config = {}
Config.DrawDistance = 10 Config.DrawDistance = 7.5
Config.MarkerSize = {x = 1.1, y = 1.1, z = 0.9} Config.MarkerSize = {x = 1.1, y = 0.7, z = 1.1}
Config.MarkerType = 29 Config.MarkerType = 29
Config.MarkerColor = {r = 102, g = 102, b = 204, a = 255} Config.MarkerColor = {r = 50, g = 200, b = 50, a = 200}
Config.Locale = 'en' Config.Locale = 'en'
Config.Zones = { Config.Zones = {
@@ -30,7 +30,7 @@ Config.Zones = {
vector3(2678.9, 3280.6, 55.2), vector3(2678.9, 3280.6, 55.2),
vector3(1729.2, 6414.1, 35.0) vector3(1729.2, 6414.1, 35.0)
}, },
Size = 1.0, Size = 0.8,
Type = 59, Type = 59,
Color = 25, Color = 25,
ShowBlip = true, ShowBlip = true,
@@ -61,7 +61,7 @@ Config.Zones = {
vector3(-1393.4, -606.6, 30.3), --Tequila la vector3(-1393.4, -606.6, 30.3), --Tequila la
vector3(-559.9, 287.0, 82.1) --Bahamamas vector3(-559.9, 287.0, 82.1) --Bahamamas
}, },
Size = 1.0, Size = 0.8,
Type = 59, Type = 59,
Color = 25, Color = 25,
ShowBlip = true, ShowBlip = true,
@@ -88,7 +88,7 @@ Config.Zones = {
vector3(-1820.5, 792.5, 138.1), vector3(-1820.5, 792.5, 138.1),
vector3(1698.3, 4924.4, 42.0) vector3(1698.3, 4924.4, 42.0)
}, },
Size = 1.0, Size = 0.8,
Type = 59, Type = 59,
Color = 25, Color = 25,
ShowBlip = true, ShowBlip = true,
+4 -4
View File
@@ -1,11 +1,11 @@
Locales['en'] = { Locales['en'] = {
['shop'] = 'shop', ['shop'] = 'shop',
['shops'] = 'shops', ['shops'] = 'shops',
['press_menu'] = 'press [E] to access the store.', ['press_menu'] = 'press [E] to access the ~g~store.',
['shop_item'] = '$%s', ['shop_item'] = '$%s',
['bought'] = 'you just bought %sx %s for ~r~$%s', ['bought'] = 'You Have Bought ~b~%sx %s~s~ for ~b~$%s',
['not_enough'] = 'you do not have ~r~enough money, you\'re missing ~r~$%s!', ['not_enough'] = 'you do ~r~not~s~ have enough money, you\'re missing ~b~$%s!',
['player_cannot_hold'] = 'you do ~r~not have enough free space in your inventory!', ['player_cannot_hold'] = 'you do ~r~not~s~ have enough free space in your inventory!',
['shop_confirm'] = 'buy %sx %s for $%s?', ['shop_confirm'] = 'buy %sx %s for $%s?',
['no'] = 'no', ['no'] = 'no',
['yes'] = 'yes', ['yes'] = 'yes',