mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-31 10:18:54 +00:00
Fixed restarting script losing licenses
This commit is contained in:
+9
-15
@@ -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
@@ -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
@@ -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'))
|
||||
|
||||
Reference in New Issue
Block a user