diff --git a/client/main.lua b/client/main.lua index 878e3427..f6d6cc3f 100644 --- a/client/main.lua +++ b/client/main.lua @@ -16,7 +16,6 @@ local LastZone = nil local CurrentAction = nil local CurrentActionMsg = '' local CurrentActionData = {} -local Licenses = {} Citizen.CreateThread(function() while ESX == nil do @@ -38,13 +37,6 @@ AddEventHandler('esx_weashop:sendShop', function(shopItems) end end) -RegisterNetEvent('esx_weashop:loadLicenses') -AddEventHandler('esx_weashop:loadLicenses', function(licenses) - for i = 1, #licenses, 1 do - Licenses[licenses[i].type] = true - end -end) - function OpenBuyLicenseMenu(zone) ESX.UI.Menu.CloseAll() @@ -112,7 +104,7 @@ end) -- Create Blips Citizen.CreateThread(function() for k,v in pairs(Config.Zones) do - if v.legal==0 then + if v.legal then for i = 1, #v.Pos, 1 do local blip = AddBlipForCoord(v.Pos[i].x, v.Pos[i].y, v.Pos[i].z) @@ -188,12 +180,14 @@ Citizen.CreateThread(function() if IsControlJustReleased(0, Keys['E']) then if CurrentAction == 'shop_menu' then - if Config.LicenseEnable then - if Licenses['weapon'] ~= nil or Config.Zones[CurrentActionData.zone].legal == 1 then - OpenShopMenu(CurrentActionData.zone) - else - OpenBuyLicenseMenu(CurrentActionData.zone) - end + 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) end diff --git a/config.lua b/config.lua index 2406ec53..9f0673e0 100644 --- a/config.lua +++ b/config.lua @@ -5,12 +5,13 @@ Config.Color = { r = 0, g = 128, b = 255 } Config.Type = 1 Config.Locale = 'fr' Config.EnableLicense = true -- only turn this on if you are using esx_license + Config.LicensePrice = 5000 Config.Zones = { GunShop = { - legal = 0, + legal = true, Items = {}, Pos = { { x = -662.180, y = -934.961, z = 20.829 }, @@ -27,7 +28,7 @@ Config.Zones = { }, BlackWeashop = { - legal = 1, + legal = false, Items = {}, Pos = { { x = -1306.239, y = -394.018, z = 35.695 }, diff --git a/server/main.lua b/server/main.lua index e6154273..fc531eed 100644 --- a/server/main.lua +++ b/server/main.lua @@ -27,18 +27,6 @@ ESX.RegisterServerCallback('esx_weashop:getShop', function(source, cb) cb(shopItems) end) -function LoadLicenses(source) - TriggerEvent('esx_license:getLicenses', source, function(licenses) - TriggerClientEvent('esx_weashop:loadLicenses', source, licenses) - end) -end - -if Config.LicenseEnable then - AddEventHandler('esx:playerLoaded', function(source) - LoadLicenses(source) - end) -end - ESX.RegisterServerCallback('esx_weashop:buyLicense', function(source, cb) local xPlayer = ESX.GetPlayerFromId(source) @@ -46,10 +34,8 @@ ESX.RegisterServerCallback('esx_weashop:buyLicense', function(source, cb) xPlayer.removeMoney(Config.LicensePrice) TriggerEvent('esx_license:addLicense', source, 'weapon', function() - LoadLicenses(source) + cb(true) end) - - cb(true) else cb(false) TriggerClientEvent('esx:showNotification', source, _U('not_enough'))