diff --git a/README.md b/README.md
index 8bef861b..6af3efba 100644
--- a/README.md
+++ b/README.md
@@ -4,19 +4,43 @@ Shops with accessories (hat/helmet, glasses, masks, ears accessories). You can p
/!\ Works only with accessories purchased in the special areas of the clothing store, not via the esx_clotheshop script.
-
-## REQUIREMENTS
-
+## Requirements
- [esx_skin](https://github.com/ESX-Org/esx_skin)
- [esx_datastore](https://github.com/ESX-Org/esx_datastore)
-## INSTALLATION
+## Download & Installation
-1) CD in your resources/[esx] folder
-2) Clone the repository
-3) Import esx_accessories.sql in your database
-4) Add this in your server.cfg :
+### Using [fvm](https://github.com/qlaffont/fvm-installer)
+```
+fvm install --save --folder=esx esx-org/esx_accessories
+```
+
+### Using Git
+```
+cd resources
+git clone https://github.com/ESX-Org/esx_accessories [esx]/esx_accessories
+```
+
+### Manually
+- Download https://github.com/ESX-Org/esx_accessories/archive/master.zip
+- Put it in the `[esx]` directory
+
+## Installation
+- Import `esx_accessories.sql` in your database
+- Add this in your `server.cfg`:
```
start esx_accessories
```
+
+# Legal
+### License
+esx_accessories - buy some shiny stuff!
+
+Copyright (C) 2015-2018 Jérémie N'gadi
+
+This program Is free software: you can redistribute it And/Or modify it under the terms Of the GNU General Public License As published by the Free Software Foundation, either version 3 Of the License, Or (at your option) any later version.
+
+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/.
diff --git a/__resource.lua b/__resource.lua
index 503cad78..8e0c1769 100644
--- a/__resource.lua
+++ b/__resource.lua
@@ -2,13 +2,14 @@ resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937'
description 'ESX Accessories'
-version '1.0.1'
+version '1.1.0'
server_scripts {
'@es_extended/locale.lua',
'locales/en.lua',
'locales/fi.lua',
'locales/fr.lua',
+ 'locales/sv.lua',
'config.lua',
'server/main.lua'
}
@@ -18,6 +19,13 @@ client_scripts {
'locales/en.lua',
'locales/fi.lua',
'locales/fr.lua',
+ 'locales/sv.lua',
'config.lua',
'client/main.lua'
}
+
+dependencies {
+ 'es_extended',
+ 'esx_skin',
+ 'esx_datastore'
+}
\ No newline at end of file
diff --git a/client/main.lua b/client/main.lua
index ea1b2813..03901014 100644
--- a/client/main.lua
+++ b/client/main.lua
@@ -9,14 +9,14 @@ local Keys = {
["LEFT"] = 174, ["RIGHT"] = 175, ["TOP"] = 27, ["DOWN"] = 173,
["NENTER"] = 201, ["N4"] = 108, ["N5"] = 60, ["N6"] = 107, ["N+"] = 96, ["N-"] = 97, ["N7"] = 117, ["N8"] = 61, ["N9"] = 118
}
-
-ESX = nil
-local HasAlreadyEnteredMarker = false
-local LastZone = nil
-local CurrentAction = nil
-local CurrentActionMsg = ''
-local CurrentActionData = {}
-local isDead = false
+
+ESX = nil
+local HasAlreadyEnteredMarker = false
+local LastZone = nil
+local CurrentAction = nil
+local CurrentActionMsg = ''
+local CurrentActionData = {}
+local isDead = false
Citizen.CreateThread(function()
while ESX == nil do
@@ -26,39 +26,33 @@ Citizen.CreateThread(function()
end)
function OpenAccessoryMenu()
+ ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'set_unset_accessory',
+ {
+ title = _U('set_unset'),
+ align = 'top-left',
+ elements = {
+ {label = _U('helmet'), value = 'Helmet'},
+ {label = _U('ears'), value = 'Ears'},
+ {label = _U('mask'), value = 'Mask'},
+ {label = _U('glasses'), value = 'Glasses'},
+ }
+ }, function(data, menu)
+ menu.close()
+ SetUnsetAccessory(data.current.value)
- ESX.UI.Menu.Open(
- 'default', GetCurrentResourceName(), 'set_unset_accessory',
- {
- title = _U('set_unset'),
- align = 'top-left',
- elements = {
- {label = _U('helmet'), value = 'Helmet'},
- {label = _U('ears'), value = 'Ears'},
- {label = _U('mask'), value = 'Mask'},
- {label = _U('glasses'), value = 'Glasses'},
- }
- },
- function(data, menu)
- menu.close()
- SetUnsetAccessory(data.current.value)
-
- end,
- function(data, menu)
- menu.close()
- end
- )
+ end, function(data, menu)
+ menu.close()
+ end)
end
function SetUnsetAccessory(accessory)
-
ESX.TriggerServerCallback('esx_accessories:get', function(hasAccessory, accessorySkin)
local _accessory = string.lower(accessory)
if hasAccessory then
TriggerEvent('skinchanger:getSkin', function(skin)
local mAccessory = -1
- local mColor = 0
+ local mColor = 0
if _accessory == "mask" then
mAccessory = 0
end
@@ -79,7 +73,6 @@ function SetUnsetAccessory(accessory)
end
function OpenShopMenu(accessory)
-
local _accessory = string.lower(accessory)
local restrict = {}
@@ -89,70 +82,63 @@ function OpenShopMenu(accessory)
menu.close()
- ESX.UI.Menu.Open(
- 'default', GetCurrentResourceName(), 'shop_confirm',
- {
- title = _U('valid_purchase'),
- align = 'top-left',
- elements = {
- {label = _U('yes'), value = 'yes'},
- {label = _U('no'), value = 'no'},
- }
- },
- function(data, menu)
- menu.close()
- if data.current.value == 'yes' then
- ESX.TriggerServerCallback('esx_accessories:checkMoney', function(hasEnoughMoney)
- if hasEnoughMoney then
- TriggerServerEvent('esx_accessories:pay')
- TriggerEvent('skinchanger:getSkin', function(skin)
- TriggerServerEvent('esx_accessories:save', skin, accessory)
- end)
- else
- TriggerEvent('esx_skin:getLastSkin', function(skin)
- TriggerEvent('skinchanger:loadSkin', skin)
- end)
- ESX.ShowNotification(_U('not_enough_money'))
- end
- end)
- end
-
- if data.current.value == 'no' then
- local player = GetPlayerPed(-1)
- TriggerEvent('esx_skin:getLastSkin', function(skin)
- TriggerEvent('skinchanger:loadSkin', skin)
- end)
- if accessory == "Ears" then
- ClearPedProp(player, 2)
- elseif accessory == "Mask" then
- SetPedComponentVariation(player, 1, 0 ,0 ,2)
- elseif accessory == "Helmet" then
- ClearPedProp(player, 0)
- elseif accessory == "Glasses" then
- SetPedPropIndex(player, 1, -1, 0, 0)
+ ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'shop_confirm',
+ {
+ title = _U('valid_purchase'),
+ align = 'top-left',
+ elements = {
+ {label = _U('no'), value = 'no'},
+ {label = _U('yes', Config.Price), value = 'yes'}
+ }
+ }, function(data, menu)
+ menu.close()
+ if data.current.value == 'yes' then
+ ESX.TriggerServerCallback('esx_accessories:checkMoney', function(hasEnoughMoney)
+ if hasEnoughMoney then
+ TriggerServerEvent('esx_accessories:pay')
+ TriggerEvent('skinchanger:getSkin', function(skin)
+ TriggerServerEvent('esx_accessories:save', skin, accessory)
+ end)
+ else
+ TriggerEvent('esx_skin:getLastSkin', function(skin)
+ TriggerEvent('skinchanger:loadSkin', skin)
+ end)
+ ESX.ShowNotification(_U('not_enough_money'))
end
- end
- CurrentAction = 'shop_menu'
- CurrentActionMsg = _U('press_access')
- CurrentActionData = {}
- end,
- function(data, menu)
- menu.close()
- CurrentAction = 'shop_menu'
- CurrentActionMsg = _U('press_access')
- CurrentActionData = {}
-
+ end)
end
- )
- end,
- function(data, menu)
+ if data.current.value == 'no' then
+ local player = GetPlayerPed(-1)
+ TriggerEvent('esx_skin:getLastSkin', function(skin)
+ TriggerEvent('skinchanger:loadSkin', skin)
+ end)
+ if accessory == "Ears" then
+ ClearPedProp(player, 2)
+ elseif accessory == "Mask" then
+ SetPedComponentVariation(player, 1, 0 ,0 ,2)
+ elseif accessory == "Helmet" then
+ ClearPedProp(player, 0)
+ elseif accessory == "Glasses" then
+ SetPedPropIndex(player, 1, -1, 0, 0)
+ end
+ end
+ CurrentAction = 'shop_menu'
+ CurrentActionMsg = _U('press_access')
+ CurrentActionData = {}
+ end, function(data, menu)
+ menu.close()
+ CurrentAction = 'shop_menu'
+ CurrentActionMsg = _U('press_access')
+ CurrentActionData = {}
+
+ end)
+ end, function(data, menu)
menu.close()
CurrentAction = 'shop_menu'
CurrentActionMsg = _U('press_access')
CurrentActionData = {}
end, restrict)
-
end
AddEventHandler('playerSpawned', function()
@@ -188,7 +174,7 @@ Citizen.CreateThread(function()
SetBlipAsShortRange(blip, true)
BeginTextCommandSetBlipName("STRING")
- AddTextComponentString(_U('shop') .. ' ' .. _U(string.lower(k)))
+ AddTextComponentString(_U('shop', _U(string.lower(k))))
EndTextCommandSetBlipName(blip)
end
end
@@ -240,21 +226,22 @@ Citizen.CreateThread(function()
end
end)
-
-- Key controls
Citizen.CreateThread(function()
while true do
Citizen.Wait(10)
if CurrentAction ~= nil then
- SetTextComponentFormat('STRING')
- AddTextComponentString(CurrentActionMsg)
- DisplayHelpTextFromStringLabel(0, 0, 1, -1)
- if IsControlJustReleased(0, 38) and CurrentActionData.accessory ~= nil then
+ ESX.ShowHelpNotification(CurrentActionMsg)
+
+ if IsControlJustReleased(0, Keys['E']) and CurrentActionData.accessory then
OpenShopMenu(CurrentActionData.accessory)
CurrentAction = nil
end
+
+ elseif CurrentAction == nil and not Config.EnableControls then
+ Citizen.Wait(500)
end
if Config.EnableControls then
@@ -264,4 +251,4 @@ Citizen.CreateThread(function()
end
end
-end)
+end)
\ No newline at end of file
diff --git a/config.lua b/config.lua
index 58c0b852..ea21f3af 100644
--- a/config.lua
+++ b/config.lua
@@ -6,13 +6,11 @@ Config.Price = 100
Config.EnableControls = true
-
Config.DrawDistance = 100.0
Config.Size = {x = 1.5, y = 1.5, z = 1.0}
Config.Color = {r = 102, g = 102, b = 204}
Config.Type = 1
-
-- Fill this if you want to see the blips,
-- If you have esx_clothesshop you should not fill this
-- more than it's already filled.
@@ -40,20 +38,20 @@ Config.ShopsBlips = {
Config.Zones = {
Ears = {
Pos = {
- {x= 80.374, y= -1389.493, z= 28.406},
- {x= -709.426, y= -153.829, z= 36.535},
- {x= -163.093, y= -302.038, z= 38.853},
- {x= 420.787, y= -809.654, z= 28.611},
- {x= -817.070, y= -1075.965, z= 10.448},
- {x= -1451.300, y= -238.254, z= 48.929},
- {x= -0.756, y= 6513.685, z= 30.997},
- {x= 123.431, y= -208.060, z= 53.677},
- {x= 1687.318, y= 4827.685, z= 41.183},
- {x= 622.806, y= 2749.221, z= 41.208},
- {x= 1200.085, y= 2705.428, z= 37.342},
- {x= -1199.959, y= -782.534, z= 16.452},
- {x= -3171.867, y= 1059.632, z= 19.983},
- {x= -1095.670, y= 2709.245, z= 18.227},
+ {x= 80.374, y= -1389.493, z= 28.406},
+ {x= -709.426, y= -153.829, z= 36.535},
+ {x= -163.093, y= -302.038, z= 38.853},
+ {x= 420.787, y= -809.654, z= 28.611},
+ {x= -817.070, y= -1075.96, z= 10.448},
+ {x= -1451.300, y= -238.254, z= 48.929},
+ {x= -0.756, y= 6513.685, z= 30.997},
+ {x= 123.431, y= -208.060, z= 53.677},
+ {x= 1687.318, y= 4827.685, z= 41.183},
+ {x= 622.806, y= 2749.221, z= 41.208},
+ {x= 1200.085, y= 2705.428, z= 37.342},
+ {x= -1199.959, y= -782.534, z= 16.452},
+ {x= -3171.867, y= 1059.632, z= 19.983},
+ {x= -1095.670, y= 2709.245, z= 18.227},
}
},
@@ -66,13 +64,13 @@ Config.Zones = {
Helmet = {
Pos = {
- {x= 81.576, y= -1400.602, z= 28.406},
+ {x= 81.576, y= -1400.602, z= 28.406},
{x= -705.845, y= -159.015, z= 36.535},
{x= -161.349, y= -295.774, z= 38.853},
{x= 419.319, y= -800.647, z= 28.611},
{x= -824.362, y= -1081.741, z= 10.448},
{x= -1454.888, y= -242.911, z= 48.931},
- {x= 4.770, y= 6520.935, z= 30.997},
+ {x= 4.770, y= 6520.935, z= 30.997},
{x= 121.071, y= -223.266, z= 53.377},
{x= 1689.648, y= 4818.805, z= 41.183},
{x= 613.971, y= 2749.978, z= 41.208},
@@ -85,13 +83,13 @@ Config.Zones = {
Glasses = {
Pos = {
- {x= 75.287, y= -1391.131, z= 28.406},
+ {x= 75.287, y= -1391.131, z= 28.406},
{x= -713.102, y= -160.116, z= 36.535},
{x= -156.171, y= -300.547, z= 38.853},
{x= 425.478, y= -807.866, z= 28.611},
{x= -820.853, y= -1072.940, z= 10.448},
{x= -1458.052, y= -236.783, z= 48.918},
- {x= 3.587, y= 6511.585, z= 30.997},
+ {x= 3.587, y= 6511.585, z= 30.997},
{x= 131.335, y= -212.336, z= 53.677},
{x= 1694.936, y= 4820.837, z= 41.183},
{x= 613.972, y= 2768.814, z= 41.208},
diff --git a/esx_accessories.sql b/esx_accessories.sql
index 92c65768..d10b2e1b 100644
--- a/esx_accessories.sql
+++ b/esx_accessories.sql
@@ -1,7 +1,8 @@
+USE `essentialmode`;
INSERT INTO `datastore` (name, label, shared) VALUES
- ('user_ears','Ears',0),
- ('user_glasses','Glasses',0),
- ('user_helmet','Helmet',0),
- ('user_mask','Mask',0)
+ ('user_ears', 'Ears', 0),
+ ('user_glasses', 'Glasses', 0),
+ ('user_helmet', 'Helmet', 0),
+ ('user_mask', 'Mask', 0)
;
diff --git a/locales/en.lua b/locales/en.lua
index b85a3473..2cb77f7d 100644
--- a/locales/en.lua
+++ b/locales/en.lua
@@ -1,13 +1,12 @@
Locales ['en'] = {
-
['valid_purchase'] = 'validate this purchase?',
- ['yes'] = 'yes',
+ ['yes'] = 'yes ($%s)',
['no'] = 'no',
['helmet'] = 'helmet / Hat',
['glasses'] = 'glasses',
['mask'] = 'mask',
['ears'] = 'ears accessories',
- ['shop'] = 'shop of',
+ ['shop'] = '%s shop',
['set_unset'] = 'put on / Take off',
['not_enough_money'] = 'you do not have enough money',
['press_access'] = 'press ~INPUT_CONTEXT~ to access the menu',
@@ -16,6 +15,5 @@ Locales ['en'] = {
['no_glasses'] = 'you do not have glasses',
['no_helmet'] = 'you do not have a helmet',
['no_mask'] = 'you do not have a mask',
- ['you_paid'] = 'you paid ',
-
+ ['you_paid'] = 'you paid ~g~$%s~s~',
}
diff --git a/locales/fi.lua b/locales/fi.lua
index 55b84afb..4b8748bc 100644
--- a/locales/fi.lua
+++ b/locales/fi.lua
@@ -1,13 +1,12 @@
Locales ['fi'] = {
-
['valid_purchase'] = 'varmista ostos?',
- ['yes'] = 'kyllä',
+ ['yes'] = 'kyllä ($%s)',
['no'] = 'ei',
['helmet'] = 'kypärä / Hattu',
['glasses'] = 'lasit',
['mask'] = 'maskit',
['ears'] = 'korva asusteet',
- ['shop'] = 'asustekauppa',
+ ['shop'] = '%s asustekauppa',
['set_unset'] = 'laita päälle / Ota pois',
['not_enough_money'] = 'sinulla ei ole tarpeeksi rahaa',
['press_access'] = 'paina ~INPUT_CONTEXT~ avataksesi menu',
@@ -16,6 +15,5 @@ Locales ['fi'] = {
['no_glasses'] = 'sinulla ei ole laseja',
['no_helmet'] = 'sinulla ei ole kypäriä',
['no_mask'] = 'sinulla ei ole maskeja',
- ['you_paid'] = 'sinä maksoit ',
-
+ ['you_paid'] = 'sinä maksoit ~g~$%s~s~',
}
diff --git a/locales/fr.lua b/locales/fr.lua
index 665c4eed..c6a02037 100644
--- a/locales/fr.lua
+++ b/locales/fr.lua
@@ -1,13 +1,12 @@
Locales ['fr'] = {
-
- ['valid_purchase'] = 'valider cet achat ?',
- ['yes'] = 'oui',
+ ['valid_purchase'] = 'valider cet achat?',
+ ['yes'] = 'oui ($%s)',
['no'] = 'non',
['helmet'] = 'casque / Chapeau',
['glasses'] = 'lunettes',
['mask'] = 'masque',
['ears'] = 'accessoires d\'oreilles',
- ['shop'] = 'magasin de',
+ ['shop'] = '%s magasin de',
['set_unset'] = 'mettre / Enlever',
['not_enough_money'] = 'vous n\'avez pas assez d\'argent',
['press_access'] = 'appuyez sur ~INPUT_CONTEXT~ pour accéder au menu',
@@ -16,6 +15,5 @@ Locales ['fr'] = {
['no_glasses'] = 'vous n\'avez pas de lunettes',
['no_helmet'] = 'vous n\'avez pas de casque / chapeau',
['no_mask'] = 'vous n\'avez pas de masque',
- ['you_paid'] = 'vous avez payé ',
-
+ ['you_paid'] = 'vous avez payé ~g~$%s~s~',
}
diff --git a/locales/sv.lua b/locales/sv.lua
new file mode 100644
index 00000000..54f99179
--- /dev/null
+++ b/locales/sv.lua
@@ -0,0 +1,19 @@
+Locales ['sv'] = {
+ ['valid_purchase'] = 'bekräfta köp?',
+ ['yes'] = 'ja (%s SEK)',
+ ['no'] = 'nej',
+ ['helmet'] = 'hjälm / hat',
+ ['glasses'] = 'glasögon',
+ ['mask'] = 'ansiktsmask',
+ ['ears'] = 'örontillbehör',
+ ['shop'] = '%s affär',
+ ['set_unset'] = 'ta på / av',
+ ['not_enough_money'] = 'du har inte råd!',
+ ['press_access'] = 'tryck ~INPUT_CONTEXT~ för att öppna menyn.',
+ ['accessories_blip'] = 'extrautröstning',
+ ['no_ears'] = 'du har inga öron tillbehör',
+ ['no_glasses'] = 'du har inga glasögon',
+ ['no_helmet'] = 'du har ingen hjälm',
+ ['no_mask'] = 'du har inte någon mask',
+ ['you_paid'] = 'du har betalat ~g~%s SEK~s~',
+}
diff --git a/localization/fi_esx_accessories.sql b/localization/fi_esx_accessories.sql
index 74b2dd57..81defba5 100644
--- a/localization/fi_esx_accessories.sql
+++ b/localization/fi_esx_accessories.sql
@@ -1,7 +1,8 @@
+USE `essentialmode`;
INSERT INTO `datastore` (name, label, shared) VALUES
- ('user_ears','Korvat',0),
- ('user_glasses','Lasit',0),
- ('user_helmet','Kypärät',0),
- ('user_mask','Maskit',0)
+ ('user_ears', 'Örontilbb', 0),
+ ('user_glasses', 'Lasit', 0),
+ ('user_helmet', 'Kypärät', 0),
+ ('user_mask', 'Maskit', 0)
;
diff --git a/localization/sv_esx_accessories.sql b/localization/sv_esx_accessories.sql
new file mode 100644
index 00000000..b947b632
--- /dev/null
+++ b/localization/sv_esx_accessories.sql
@@ -0,0 +1,8 @@
+USE `essentialmode`;
+
+INSERT INTO `datastore` (name, label, shared) VALUES
+ ('user_ears', 'Örontillbehör', 0),
+ ('user_glasses', 'Glasögon', 0),
+ ('user_helmet', 'Hjälm', 0),
+ ('user_mask', 'Mask', 0)
+;
diff --git a/server/main.lua b/server/main.lua
index b2d0887c..1b614f92 100644
--- a/server/main.lua
+++ b/server/main.lua
@@ -7,7 +7,7 @@ AddEventHandler('esx_accessories:pay', function()
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
xPlayer.removeMoney(Config.Price)
- TriggerClientEvent('esx:showNotification', _source, _U('you_paid') .. '$' .. Config.Price)
+ TriggerClientEvent('esx:showNotification', _source, _U('you_paid', Config.Price))
end)
@@ -32,8 +32,7 @@ AddEventHandler('esx_accessories:save', function(skin, accessory)
end)
ESX.RegisterServerCallback('esx_accessories:get', function(source, cb, accessory)
- local _source = source
- local xPlayer = ESX.GetPlayerFromId(_source)
+ local xPlayer = ESX.GetPlayerFromId(source)
TriggerEvent('esx_datastore:getDataStore', 'user_' .. string.lower(accessory), xPlayer.identifier, function(store)
@@ -46,12 +45,8 @@ ESX.RegisterServerCallback('esx_accessories:get', function(source, cb, accessory
end)
---===================================================================
---===================================================================
-
ESX.RegisterServerCallback('esx_accessories:checkMoney', function(source, cb)
- local _source = source
- local xPlayer = ESX.GetPlayerFromId(_source)
+ local xPlayer = ESX.GetPlayerFromId(source)
if xPlayer.get('money') >= Config.Price then
cb(true)