From 6ccd047cb6fa42e61af734a12627d93717a4af56 Mon Sep 17 00:00:00 2001 From: RoadToSix <92928205+RoadPhone@users.noreply.github.com> Date: Thu, 24 Mar 2022 15:46:45 +0100 Subject: [PATCH 1/9] Update fxmanifest.lua --- [esx_addons]/esx_atm/fxmanifest.lua | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/[esx_addons]/esx_atm/fxmanifest.lua b/[esx_addons]/esx_atm/fxmanifest.lua index 9d6f4325..bae5d469 100644 --- a/[esx_addons]/esx_atm/fxmanifest.lua +++ b/[esx_addons]/esx_atm/fxmanifest.lua @@ -6,33 +6,18 @@ description 'ESX Atm' version '1.6.5' -shared_script '@es_extended/imports.lua' +shared_scripts { + '@es_extended/imports.lua', + '@es_extended/locale.lua', + 'locales/*.lua', + 'config.lua' +} server_scripts { - '@es_extended/locale.lua', - 'locales/de.lua', - 'locales/br.lua', - 'locales/en.lua', - 'locales/fi.lua', - 'locales/fr.lua', - 'locales/es.lua', - 'locales/sv.lua', - 'locales/cs.lua', - 'config.lua', 'server/main.lua' } client_scripts { - '@es_extended/locale.lua', - 'locales/de.lua', - 'locales/br.lua', - 'locales/en.lua', - 'locales/fi.lua', - 'locales/fr.lua', - 'locales/es.lua', - 'locales/sv.lua', - 'locales/cs.lua', - 'config.lua', 'client/main.lua' } From 232b5da2719f8d349d0fdb62db2bcc9f36c74d58 Mon Sep 17 00:00:00 2001 From: Fezz <43589668+FBFezz@users.noreply.github.com> Date: Sat, 26 Mar 2022 15:08:55 +0000 Subject: [PATCH 2/9] Update fxmanifest.lua --- [esx_addons]/esx_joblisting/fxmanifest.lua | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/[esx_addons]/esx_joblisting/fxmanifest.lua b/[esx_addons]/esx_joblisting/fxmanifest.lua index 16c15c27..e2c73a61 100644 --- a/[esx_addons]/esx_joblisting/fxmanifest.lua +++ b/[esx_addons]/esx_joblisting/fxmanifest.lua @@ -1,5 +1,4 @@ -fx_version 'adamant' - +fx_version 'bodacious' game 'gta5' description 'ESX Job Listing' @@ -9,17 +8,12 @@ version '1.6.5' shared_scripts { '@es_extended/imports.lua', '@es_extended/locale.lua', + 'locales/*.lua', 'config.lua' } -server_scripts { - '@oxmysql/lib/MySQL.lua', - 'locales/*.lua', - 'server/main.lua' -} -client_scripts { - 'locales/*.lua', - 'client/main.lua' -} +server_script 'server/main.lua' + +client_script 'client/main.lua' dependency 'es_extended' From 894668f7c9d4f2e3dfadb4f4f77ab66492698d71 Mon Sep 17 00:00:00 2001 From: Fezz <43589668+FBFezz@users.noreply.github.com> Date: Sat, 26 Mar 2022 15:09:18 +0000 Subject: [PATCH 3/9] Fixed Not Showing Jobs --- [esx_addons]/esx_joblisting/server/main.lua | 22 +++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/[esx_addons]/esx_joblisting/server/main.lua b/[esx_addons]/esx_joblisting/server/main.lua index 823f10b3..7190ed08 100644 --- a/[esx_addons]/esx_joblisting/server/main.lua +++ b/[esx_addons]/esx_joblisting/server/main.lua @@ -1,14 +1,18 @@ -local availableJobs = {} - -for k,v in pairs(ESX.Jobs) do - print(v.whitelisted) - if v.whitelisted == false then - availableJobs[k] = {label = v.label} +function getJobs() + local jobs = ESX.GetJobs() + local availableJobs = {} + for k,v in pairs(jobs) do + print(v.whitelisted) + if v.whitelisted == false then + availableJobs[k] = {label = v.label} + end end + return availableJobs end ESX.RegisterServerCallback('esx_joblisting:getJobsList', function(source, cb) - cb(availableJobs) + local jobs = getJobs() + cb(jobs) end) function IsNearCentre(player) @@ -27,10 +31,12 @@ end RegisterServerEvent('esx_joblisting:setJob') AddEventHandler('esx_joblisting:setJob', function(job) + local source = source local xPlayer = ESX.GetPlayerFromId(source) + local jobs = getJobs() if xPlayer and IsNearCentre(source) then - if availableJobs[job] then + if jobs[job] then xPlayer.setJob(job, 0) end end From 9b9ce389384a7de3f077af444107800b001599bb Mon Sep 17 00:00:00 2001 From: Mycroft Date: Sat, 26 Mar 2022 18:58:59 +0000 Subject: [PATCH 4/9] Refactor: ESX Whitelist --- [esx_addons]/esx_whitelist/README.md | 26 -------- [esx_addons]/esx_whitelist/esx_whitelist.sql | 8 --- [esx_addons]/esx_whitelist/fxmanifest.lua | 6 +- [esx_addons]/esx_whitelist/locales/en.lua | 8 +-- [esx_addons]/esx_whitelist/players.json | 1 + .../esx_whitelist/server/commands.lua | 26 -------- [esx_addons]/esx_whitelist/server/main.lua | 61 +++++++++++++------ 7 files changed, 52 insertions(+), 84 deletions(-) delete mode 100644 [esx_addons]/esx_whitelist/esx_whitelist.sql create mode 100644 [esx_addons]/esx_whitelist/players.json delete mode 100644 [esx_addons]/esx_whitelist/server/commands.lua diff --git a/[esx_addons]/esx_whitelist/README.md b/[esx_addons]/esx_whitelist/README.md index a6a9cf72..9ea7a128 100644 --- a/[esx_addons]/esx_whitelist/README.md +++ b/[esx_addons]/esx_whitelist/README.md @@ -1,32 +1,6 @@ # esx_whitelist -## Download & Installation - -### Using [fvm](https://github.com/qlaffont/fvm-installer) -``` -fvm install --save --folder=esx esx-org/esx_whitelist -``` - -### Using Git -``` -cd resources -git clone https://github.com/ESX-Org/esx_whitelist [esx]/esx_whitelist -``` - -### Manually -- Download https://github.com/ESX-Org/esx_whitelist/archive/master.zip -- Put it in the `[esx]` directory - -## Installation -- Import `esx_whitelist.sql` to your database -- Add this in your `server.cfg`: - -``` -start esx_whitelist -``` - # Legal -### License esx_whitelist - Whitelist script Copyright (C) 2015-2022 Jérémie N'gadi diff --git a/[esx_addons]/esx_whitelist/esx_whitelist.sql b/[esx_addons]/esx_whitelist/esx_whitelist.sql deleted file mode 100644 index 68bcf92a..00000000 --- a/[esx_addons]/esx_whitelist/esx_whitelist.sql +++ /dev/null @@ -1,8 +0,0 @@ -USE `es_extended`; - -CREATE TABLE `whitelist` ( - `identifier` varchar(60) NOT NULL, - - PRIMARY KEY (`identifier`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; - diff --git a/[esx_addons]/esx_whitelist/fxmanifest.lua b/[esx_addons]/esx_whitelist/fxmanifest.lua index 6319d5d9..1ea8d736 100644 --- a/[esx_addons]/esx_whitelist/fxmanifest.lua +++ b/[esx_addons]/esx_whitelist/fxmanifest.lua @@ -6,12 +6,12 @@ description 'ESX Whitelist' version '1.6.5' +server_only 'yes' + server_scripts { '@es_extended/imports.lua', - '@oxmysql/lib/MySQL.lua', '@es_extended/locale.lua', 'config.lua', 'locales/*.lua', - 'server/main.lua', - 'server/commands.lua' + 'server/main.lua' } diff --git a/[esx_addons]/esx_whitelist/locales/en.lua b/[esx_addons]/esx_whitelist/locales/en.lua index 8b7443c6..398c3964 100644 --- a/[esx_addons]/esx_whitelist/locales/en.lua +++ b/[esx_addons]/esx_whitelist/locales/en.lua @@ -1,8 +1,8 @@ Locales['en'] = { - ['whitelist_check'] = 'making sure you\'re whitelisted on this server . . .', - ['not_whitelisted'] = 'you are not whitelisted on this server', - ['whitelist_empty'] = 'the whitelist hasn\'t been loaded yet, or alternatively no one has been whitelisted!', - ['license_missing'] = 'your license could not be found', + ['whitelist_check'] = 'Checking you are Allowlisted.', + ['not_whitelisted'] = 'You Must be Allowlisted to join this server!', + ['whitelist_empty'] = 'There Are no whitelists saved for this server.', + ['license_missing'] = 'Error: Your Identifier is missing!', ['help_whitelist_add'] = 'add someone to the whitelist', ['help_whitelist_load'] = 'reload the whitelist', } diff --git a/[esx_addons]/esx_whitelist/players.json b/[esx_addons]/esx_whitelist/players.json new file mode 100644 index 00000000..0637a088 --- /dev/null +++ b/[esx_addons]/esx_whitelist/players.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/[esx_addons]/esx_whitelist/server/commands.lua b/[esx_addons]/esx_whitelist/server/commands.lua deleted file mode 100644 index e9d8193e..00000000 --- a/[esx_addons]/esx_whitelist/server/commands.lua +++ /dev/null @@ -1,26 +0,0 @@ -ESX.RegisterCommand('wlrefresh', 'admin', function(xPlayer, args, showError) - loadWhiteList(function() - showError('Whitelist reloaded') - end) -end, true, {help = _U('help_whitelist_load')}) - -ESX.RegisterCommand('wladd', 'admin', function(xPlayer, args, showError) - args.license = args.license:lower() - - if string.len(args.license) == 40 then - if WhiteList[args.license] then - showError('The player is already whitelisted on this server!') - else - MySQL.update('INSERT INTO whitelist (identifier) VALUES (@identifier)', { - ['@identifier'] = args.license - }, function(rowsChanged) - WhiteList[args.license] = true - showError('The player has been whitelisted!') - end) - end - else - showError('Invalid license ID length!') - end -end, true, {help = _U('help_whitelist_add'), validate = true, arguments = { - {name = 'license', help = 'the player license', type = 'string'} -}}) diff --git a/[esx_addons]/esx_whitelist/server/main.lua b/[esx_addons]/esx_whitelist/server/main.lua index 399ed818..2983e090 100644 --- a/[esx_addons]/esx_whitelist/server/main.lua +++ b/[esx_addons]/esx_whitelist/server/main.lua @@ -1,28 +1,20 @@ WhiteList = {} -function loadWhiteList(cb) - Whitelist = {} +function loadWhiteList() + Whitelist = nil - MySQL.query('SELECT identifier FROM whitelist', function(result) - for k,v in ipairs(result) do - WhiteList[v.identifier] = true - end - - if cb then - cb() - end - end) + local List = LoadResourceFile(GetCurrentResourceName(),'players.json') + if List then + Whitelist = json.decode(List) + end end -MySQL.ready(function() - loadWhiteList() -end) +loadWhiteList() AddEventHandler('playerConnecting', function(name, setCallback, deferrals) - if #GetPlayers() < Config.MinPlayer then + if #(GetPlayers()) < Config.MinPlayer then deferrals.done() - end - + else -- Mark this connection as deferred, this is to prevent problems while checking player identifiers. deferrals.defer() @@ -49,4 +41,39 @@ AddEventHandler('playerConnecting', function(name, setCallback, deferrals) else deferrals.done() end + end end) + +ESX.RegisterCommand('wlrefresh', 'admin', function(xPlayer, args, showError) + loadWhiteList(function() + showError('Whitelist reloaded') + end) +end, true, {help = _U('help_whitelist_load')}) + +ESX.RegisterCommand('wladd', 'admin', function(xPlayer, args, showError) + args.license = args.license:lower() + + if WhiteList[args.license] then + showError('The player is already allowlisted on this server!') + else + WhiteList[args.license] = true + SaveResourceFile(GetCurrentResourceName(), 'players.json', json.encode(WhiteList)) + loadWhiteList() + end +end, true, {help = _U('help_whitelist_add'), validate = true, arguments = { + {name = 'license', help = 'the player license', type = 'string'} +}}) + +ESX.RegisterCommand('wlremove', 'admin', function(xPlayer, args, showError) + args.license = args.license:lower() + + if WhiteList[args.license] then + WhiteList[args.license] = nil + SaveResourceFile(GetCurrentResourceName(), 'players.json', json.encode(WhiteList)) + loadWhiteList() + else + showError('Identifier is not Allowlisted on this server!') + end +end, true, {help = _U('help_whitelist_add'), validate = true, arguments = { + {name = 'license', help = 'the player license', type = 'string'} +}}) From 133caab3c3b3d3c2955027a550f03cbe379ed54a Mon Sep 17 00:00:00 2001 From: Mycroft Date: Sat, 26 Mar 2022 19:43:32 +0000 Subject: [PATCH 5/9] Refactor: ESX Weaponshop --- [esx_addons]/esx_weaponshop/README.md | 26 ---- [esx_addons]/esx_weaponshop/client/main.lua | 27 +--- [esx_addons]/esx_weaponshop/config.lua | 145 +++++++++++++++++- .../esx_weaponshop/esx_weaponshop.sql | 55 +------ [esx_addons]/esx_weaponshop/fxmanifest.lua | 1 - [esx_addons]/esx_weaponshop/server/main.lua | 40 ++--- 6 files changed, 156 insertions(+), 138 deletions(-) diff --git a/[esx_addons]/esx_weaponshop/README.md b/[esx_addons]/esx_weaponshop/README.md index 827916e4..b6e29da8 100644 --- a/[esx_addons]/esx_weaponshop/README.md +++ b/[esx_addons]/esx_weaponshop/README.md @@ -2,33 +2,7 @@ ESX Weapon Shop adds.. well you guessed it - weapon shops to the already existing shops in the world. -## Download & Installation - -### Using [fvm](https://github.com/qlaffont/fvm-installer) -``` -fvm install --save --folder=esx esx-org/esx_weaponshop -``` - -### Using Git -``` -cd resources -git clone https://github.com/ESX-Org/esx_weaponshop.git [esx]/esx_weaponshop -``` - -### Manually -- Download https://github.com/ESX-Org/esx_weaponshop/archive/master.zip -- Put it in the `[esx]` directory - -## Installation -- Import `esx_weaponshop.sql` in your database -- Add this to your `server.cfg`: - -``` -start esx_weaponshop -``` - # Legal -### License esx_weaponshop - Legal and illegal weapon shops Copyright (C) 2015-2022 Jérémie N'gadi diff --git a/[esx_addons]/esx_weaponshop/client/main.lua b/[esx_addons]/esx_weaponshop/client/main.lua index d494ba0f..5b7f9d95 100644 --- a/[esx_addons]/esx_weaponshop/client/main.lua +++ b/[esx_addons]/esx_weaponshop/client/main.lua @@ -5,19 +5,6 @@ local CurrentActionMsg = '' local CurrentActionData = {} local ShopOpen = false -ESX.TriggerServerCallback('esx_weaponshop:getShop', function(shopItems) - for k,v in pairs(shopItems) do - Config.Zones[k].Items = v - end -end) - -RegisterNetEvent('esx_weaponshop:sendShop') -AddEventHandler('esx_weaponshop:sendShop', function(shopItems) - for k,v in pairs(shopItems) do - Config.Zones[k].Items = v - end -end) - function OpenBuyLicenseMenu(zone) ESX.UI.Menu.CloseAll() @@ -48,11 +35,12 @@ function OpenShopMenu(zone) for i=1, #Config.Zones[zone].Items, 1 do local item = Config.Zones[zone].Items[i] + item.label = ESX.GetWeaponLabel(item.name) table.insert(elements, { label = ('%s - %s'):format(item.label, _U('shop_menu_item', ESX.Math.GroupDigits(item.price))), price = item.price, - weaponName = item.item + weaponName = item.name }) end @@ -140,7 +128,7 @@ CreateThread(function() SetBlipSprite (blip, 110) SetBlipDisplay(blip, 4) - SetBlipScale (blip, 1.0) + SetBlipScale (blip, 0.8) SetBlipColour (blip, 81) SetBlipAsShortRange(blip, true) @@ -202,11 +190,8 @@ end) -- Key Controls CreateThread(function() - while true do - local Sleep = 1500 - - if CurrentAction ~= nil then - Sleep = 0 + while CurrentAction do + Wait(0) ESX.ShowHelpNotification(CurrentActionMsg) if IsControlJustReleased(0, 38) then @@ -227,7 +212,5 @@ CreateThread(function() CurrentAction = nil end - end - Wait(Sleep) end end) diff --git a/[esx_addons]/esx_weaponshop/config.lua b/[esx_addons]/esx_weaponshop/config.lua index 63a3b425..33da63f4 100644 --- a/[esx_addons]/esx_weaponshop/config.lua +++ b/[esx_addons]/esx_weaponshop/config.lua @@ -1,6 +1,6 @@ Config = {} -Config.DrawDistance = 10 +Config.DrawDistance = 10.0 Config.Size = { x = 1.5, y = 1.5, z = 0.5 } Config.Color = { r = 0, g = 128, b = 255 } Config.Type = 1 @@ -16,7 +16,76 @@ Config.Zones = { GunShop = { Legal = true, - Items = {}, + Items = { + { + name = "WEAPON_PISTOL", + price = 500 + }, + { + name = "WEAPON_FLASHLIGHT", + price = 70 + }, + { + name = "WEAPON_MACHETE", + price = 110 + }, + { + name = "WEAPON_NIGHTSTICK", + price = 150 + }, + { + name = "WEAPON_BAT", + price = 50 + }, + { + name = "WEAPON_STUNGUN", + price = 60 + }, + { + name = "WEAPON_MICROSMG", + price = 1700 + }, + { + name = "WEAPON_ASSAULTRIFLE", + price = 11000 + }, + { + name = "WEAPON_STUNGUN", + price = 60 + }, + { + name = "WEAPON_SPECIALCARBINE", + price = 15000 + }, + { + name = "WEAPON_SNIPERRIFLE", + price = 24000 + }, + { + name = "WEAPON_FIREWORK", + price = 21000 + }, + { + name = "WEAPON_GRENADE", + price = 700 + }, + { + name = "WEAPON_BZGAS", + price = 200 + }, + { + name = "WEAPON_FIREEXTINGUISHER", + price = 100 + }, + { + name = "WEAPON_BALL", + price = 30 + }, + { + name = "WEAPON_SMOKEGRENADE", + price = 100 + }, + }, Locations = { vector3(-662.1, -935.3, 20.8), vector3(810.2, -2157.3, 28.6), @@ -32,10 +101,78 @@ Config.Zones = { BlackWeashop = { Legal = false, - Items = {}, + Items = { + { + name = "WEAPON_PISTOL", + price = 500 + }, + { + name = "WEAPON_FLASHLIGHT", + price = 70 + }, + { + name = "WEAPON_MACHETE", + price = 110 + }, + { + name = "WEAPON_NIGHTSTICK", + price = 150 + }, + { + name = "WEAPON_BAT", + price = 50 + }, + { + name = "WEAPON_STUNGUN", + price = 60 + }, + { + name = "WEAPON_MICROSMG", + price = 1700 + }, + { + name = "WEAPON_ASSAULTRIFLE", + price = 11000 + }, + { + name = "WEAPON_STUNGUN", + price = 60 + }, + { + name = "WEAPON_SPECIALCARBINE", + price = 15000 + }, + { + name = "WEAPON_SNIPERRIFLE", + price = 24000 + }, + { + name = "WEAPON_FIREWORK", + price = 21000 + }, + { + name = "WEAPON_GRENADE", + price = 700 + }, + { + name = "WEAPON_BZGAS", + price = 200 + }, + { + name = "WEAPON_FIREEXTINGUISHER", + price = 100 + }, + { + name = "WEAPON_BALL", + price = 30 + }, + { + name = "WEAPON_SMOKEGRENADE", + price = 100 + }, + }, Locations = { vector3(-1306.2, -394.0, 35.6) } } - } diff --git a/[esx_addons]/esx_weaponshop/esx_weaponshop.sql b/[esx_addons]/esx_weaponshop/esx_weaponshop.sql index 9f866ec5..7f46bb4f 100644 --- a/[esx_addons]/esx_weaponshop/esx_weaponshop.sql +++ b/[esx_addons]/esx_weaponshop/esx_weaponshop.sql @@ -1,58 +1,5 @@ USE `es_extended`; -CREATE TABLE `weashops` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `zone` varchar(255) NOT NULL, - `item` varchar(255) NOT NULL, - `price` int(11) NOT NULL, - - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; - - INSERT INTO `licenses` (`type`, `label`) VALUES - ('weapon', "Permis de port d'arme") -; - -INSERT INTO `weashops` (`zone`, `item`, `price`) VALUES - ('GunShop','WEAPON_PISTOL', 300), - ('BlackWeashop','WEAPON_PISTOL', 500), - ('GunShop', 'WEAPON_FLASHLIGHT', 60), - ('BlackWeashop', 'WEAPON_FLASHLIGHT', 70), - ('GunShop', 'WEAPON_MACHETE', 90), - ('BlackWeashop', 'WEAPON_MACHETE', 110), - ('GunShop', 'WEAPON_NIGHTSTICK', 150), - ('BlackWeashop', 'WEAPON_NIGHTSTICK', 150), - ('GunShop', 'WEAPON_BAT', 100), - ('BlackWeashop', 'WEAPON_BAT', 100), - ('GunShop', 'WEAPON_STUNGUN', 50), - ('BlackWeashop', 'WEAPON_STUNGUN', 50), - ('GunShop', 'WEAPON_MICROSMG', 1400), - ('BlackWeashop', 'WEAPON_MICROSMG', 1700), - ('GunShop', 'WEAPON_PUMPSHOTGUN', 3400), - ('BlackWeashop', 'WEAPON_PUMPSHOTGUN', 3500), - ('GunShop', 'WEAPON_ASSAULTRIFLE', 10000), - ('BlackWeashop', 'WEAPON_ASSAULTRIFLE', 11000), - ('GunShop', 'WEAPON_SPECIALCARBINE', 15000), - ('BlackWeashop', 'WEAPON_SPECIALCARBINE', 16500), - ('GunShop', 'WEAPON_SNIPERRIFLE', 22000), - ('BlackWeashop', 'WEAPON_SNIPERRIFLE', 24000), - ('GunShop', 'WEAPON_FIREWORK', 18000), - ('BlackWeashop', 'WEAPON_FIREWORK', 20000), - ('GunShop', 'WEAPON_GRENADE', 500), - ('BlackWeashop', 'WEAPON_GRENADE', 650), - ('GunShop', 'WEAPON_BZGAS', 200), - ('BlackWeashop', 'WEAPON_BZGAS', 350), - ('GunShop', 'WEAPON_FIREEXTINGUISHER', 100), - ('BlackWeashop', 'WEAPON_FIREEXTINGUISHER', 100), - ('GunShop', 'WEAPON_BALL', 50), - ('BlackWeashop', 'WEAPON_BALL', 50), - ('GunShop', 'WEAPON_SMOKEGRENADE', 100), - ('BlackWeashop', 'WEAPON_SMOKEGRENADE', 100), - ('BlackWeashop', 'WEAPON_APPISTOL', 1100), - ('BlackWeashop', 'WEAPON_CARBINERIFLE', 12000), - ('BlackWeashop', 'WEAPON_HEAVYSNIPER', 30000), - ('BlackWeashop', 'WEAPON_MINIGUN', 45000), - ('BlackWeashop', 'WEAPON_RAILGUN', 50000), - ('BlackWeashop', 'WEAPON_STICKYBOMB', 500) + ('weapon', "Weapon licence") ; diff --git a/[esx_addons]/esx_weaponshop/fxmanifest.lua b/[esx_addons]/esx_weaponshop/fxmanifest.lua index 64296bf3..3e038edc 100644 --- a/[esx_addons]/esx_weaponshop/fxmanifest.lua +++ b/[esx_addons]/esx_weaponshop/fxmanifest.lua @@ -14,7 +14,6 @@ shared_scripts { } server_scripts { - '@oxmysql/lib/MySQL.lua', 'server/main.lua' } diff --git a/[esx_addons]/esx_weaponshop/server/main.lua b/[esx_addons]/esx_weaponshop/server/main.lua index 2f19e15b..75a7d5ca 100644 --- a/[esx_addons]/esx_weaponshop/server/main.lua +++ b/[esx_addons]/esx_weaponshop/server/main.lua @@ -1,28 +1,3 @@ -local shopItems = {} - -MySQL.ready(function() - - MySQL.query('SELECT * FROM weashops', function(result) - for i=1, #result, 1 do - if shopItems[result[i].zone] == nil then - shopItems[result[i].zone] = {} - end - - table.insert(shopItems[result[i].zone], { - item = result[i].item, - price = result[i].price, - label = ESX.GetWeaponLabel(result[i].item) - }) - end - - TriggerClientEvent('esx_weaponshop:sendShop', -1, shopItems) - end) - -end) - -ESX.RegisterServerCallback('esx_weaponshop:getShop', function(source, cb) - cb(shopItems) -end) ESX.RegisterServerCallback('esx_weaponshop:buyLicense', function(source, cb) local xPlayer = ESX.GetPlayerFromId(source) @@ -77,13 +52,16 @@ ESX.RegisterServerCallback('esx_weaponshop:buyWeapon', function(source, cb, weap end) function GetPrice(weaponName, zone) - local price = MySQL.scalar.await('SELECT price FROM weashops WHERE zone = @zone AND item = @item', { - ['@zone'] = zone, - ['@item'] = weaponName - }) + local weapon = nil + for k,v in pairs(Config.Zones[zone].items) + if v.name == weaponName then + weapon = v + break + end + end - if price then - return price + if weapon then + return v.price else return 0 end From d9f17c499406c10751e456eebbd99bb4065f9baf Mon Sep 17 00:00:00 2001 From: Mycroft Date: Sat, 26 Mar 2022 20:11:13 +0000 Subject: [PATCH 6/9] Weaponshop refactor --- [esx_addons]/esx_weaponshop/client/main.lua | 92 +++++---------------- 1 file changed, 21 insertions(+), 71 deletions(-) diff --git a/[esx_addons]/esx_weaponshop/client/main.lua b/[esx_addons]/esx_weaponshop/client/main.lua index 5b7f9d95..2b0b2930 100644 --- a/[esx_addons]/esx_weaponshop/client/main.lua +++ b/[esx_addons]/esx_weaponshop/client/main.lua @@ -83,7 +83,6 @@ function DisplayBoughtScaleform(weaponName, price) ScaleformMovieMethodAddParamInt(GetHashKey(weaponName)) ScaleformMovieMethodAddParamTextureNameString('') ScaleformMovieMethodAddParamInt(100) - EndScaleformMovieMethod() PlaySoundFrontend(-1, 'WEAPON_PURCHASE', 'HUD_AMMO_SHOP_SOUNDSET', false) @@ -98,19 +97,6 @@ function DisplayBoughtScaleform(weaponName, price) end) end -AddEventHandler('esx_weaponshop:hasEnteredMarker', function(zone) - if zone == 'GunShop' or zone == 'BlackWeashop' then - CurrentAction = 'shop_menu' - CurrentActionMsg = _U('shop_menu_prompt') - CurrentActionData = { zone = zone } - end -end) - -AddEventHandler('esx_weaponshop:hasExitedMarker', function(zone) - CurrentAction = nil - ESX.UI.Menu.CloseAll() -end) - AddEventHandler('onResourceStop', function(resource) if resource == GetCurrentResourceName() then if ShopOpen then @@ -151,66 +137,30 @@ CreateThread(function() for i = 1, #v.Locations, 1 do if (Config.Type ~= -1 and #(coords - v.Locations[i]) < Config.DrawDistance) then Sleep = 0 + ESX.ShowHelpNotification(_U('shop_menu_prompt')) + + if IsControlJustReleased(0, 38) then + if Config.LicenseEnable and v.Legal then + ESX.TriggerServerCallback('esx_license:checkLicense', function(hasWeaponLicense) + if hasWeaponLicense then + OpenShopMenu(k) + else + OpenBuyLicenseMenu(k) + end + end, GetPlayerServerId(PlayerId()), 'weapon') + else + OpenShopMenu(k) + end + end DrawMarker(Config.Type, v.Locations[i], 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, false, false, false) - end - end - end - Wait(Sleep) - end -end) - --- Enter / Exit marker events -CreateThread(function() - while true do - local Sleep = 1000 - - local coords = GetEntityCoords(PlayerPedId()) - local isInMarker, currentZone = false, nil - - for k,v in pairs(Config.Zones) do - for i=1, #v.Locations, 1 do - if #(coords - v.Locations[i]) < Config.Size.x then - Sleep = 0 - isInMarker, ShopItems, currentZone, LastZone = true, v.Items, k, k - end - end - end - if isInMarker and not HasAlreadyEnteredMarker then - HasAlreadyEnteredMarker = true - TriggerEvent('esx_weaponshop:hasEnteredMarker', currentZone) - end - - if not isInMarker and HasAlreadyEnteredMarker then - HasAlreadyEnteredMarker = false - TriggerEvent('esx_weaponshop:hasExitedMarker', LastZone) - end - Wait(Sleep) - end -end) - --- Key Controls -CreateThread(function() - while CurrentAction do - Wait(0) - ESX.ShowHelpNotification(CurrentActionMsg) - - if IsControlJustReleased(0, 38) then - - if CurrentAction == 'shop_menu' then - if Config.LicenseEnable and Config.Zones[CurrentActionData.zone].Legal then - ESX.TriggerServerCallback('esx_license:checkLicense', function(hasWeaponLicense) - if hasWeaponLicense then - OpenShopMenu(CurrentActionData.zone) - else - OpenBuyLicenseMenu(CurrentActionData.zone) - end - end, GetPlayerServerId(PlayerId()), 'weapon') - else - OpenShopMenu(CurrentActionData.zone) + else + if ShopOpen then + ESX.UI.Menu.CloseAll() + ShopOpen = false end end - - CurrentAction = nil end + end + Wait(Sleep) end end) From 65213f2c1668f37e572600f696d02ce76df2f0be Mon Sep 17 00:00:00 2001 From: iSentrie Date: Sun, 27 Mar 2022 14:33:43 +0300 Subject: [PATCH 7/9] Fixed loop --- [esx_addons]/esx_lscustom/client/main.lua | 29 ++++++++++++----------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/[esx_addons]/esx_lscustom/client/main.lua b/[esx_addons]/esx_lscustom/client/main.lua index c23fe574..765463c2 100644 --- a/[esx_addons]/esx_lscustom/client/main.lua +++ b/[esx_addons]/esx_lscustom/client/main.lua @@ -391,6 +391,21 @@ CreateThread(function() ESX.UI.Menu.CloseAll() GetAction({value = 'main'}) + + -- Prevent Free Tunning Bug + CreateThread(function() + while lsMenuIsShowed do + DisableControlAction(2, 288, true) + DisableControlAction(2, 289, true) + DisableControlAction(2, 170, true) + DisableControlAction(2, 167, true) + DisableControlAction(2, 168, true) + DisableControlAction(2, 23, true) + DisableControlAction(0, 75, true) -- Disable exit vehicle + DisableControlAction(27, 75, true) -- Disable exit vehicle + Wait(0) + end + end) end end end @@ -399,17 +414,3 @@ CreateThread(function() Wait(Sleep) end end) - --- Prevent Free Tunning Bug -CreateThread(function() - while lsMenuIsShowed do - DisableControlAction(2, 288, true) - DisableControlAction(2, 289, true) - DisableControlAction(2, 170, true) - DisableControlAction(2, 167, true) - DisableControlAction(2, 168, true) - DisableControlAction(2, 23, true) - DisableControlAction(0, 75, true) -- Disable exit vehicle - DisableControlAction(27, 75, true) -- Disable exit vehicle - end -end) From a132299ebe35d20243e38e635342a00ecc5a5182 Mon Sep 17 00:00:00 2001 From: Mycroft Date: Sun, 27 Mar 2022 15:00:12 +0100 Subject: [PATCH 8/9] Update Discord Link --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index ace393cd..4607d927 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,4 @@ -

ESX Legacy

Discord - Website - Documentation +

ESX Legacy

Discord - Website - Documentation **IMPORTANT**: ESX Legacy now supports ox Inventory. **HOWEVER, THIS SHOULD ONLY BE USED IF YOU ARE EXPERIENCED AND KNOW WHAT YOU ARE DOING**. From 7cfa2035f1f31b4b895567eaeb01834d3fb33c4d Mon Sep 17 00:00:00 2001 From: Haroki Date: Mon, 28 Mar 2022 16:30:43 +0100 Subject: [PATCH 9/9] Bug Fix: Someone forgot do :) --- [esx_addons]/esx_weaponshop/server/main.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/[esx_addons]/esx_weaponshop/server/main.lua b/[esx_addons]/esx_weaponshop/server/main.lua index 75a7d5ca..969558ae 100644 --- a/[esx_addons]/esx_weaponshop/server/main.lua +++ b/[esx_addons]/esx_weaponshop/server/main.lua @@ -53,7 +53,7 @@ end) function GetPrice(weaponName, zone) local weapon = nil - for k,v in pairs(Config.Zones[zone].items) + for k,v in pairs(Config.Zones[zone].items) do if v.name == weaponName then weapon = v break