Fixed restarting script losing licenses

This commit is contained in:
ElPumpo
2018-11-17 22:43:41 +01:00
parent d2a369e825
commit b0d73a4d79
3 changed files with 13 additions and 32 deletions
+9 -15
View File
@@ -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
+3 -2
View File
@@ -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 },
+1 -15
View File
@@ -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'))