feat(license): add license support

This commit is contained in:
Romain Lanz
2017-10-14 23:55:24 +02:00
parent 4803dac2f5
commit 29d96bf1af
5 changed files with 85 additions and 10 deletions
+29
View File
@@ -3,6 +3,35 @@ local ItemsLabels = {}
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
function LoadLicenses (source)
TriggerEvent('esx_license:getLicenses', source, function (licenses)
TriggerClientEvent('esx_weashop:loadLicenses', source, licenses)
end)
end
if Config.EnableLicense == true then
AddEventHandler('esx:playerLoaded', function (source)
LoadLicenses(source)
end)
end
RegisterServerEvent('esx_weashop:buyLicense')
AddEventHandler('esx_weashop:buyLicense', function ()
local _source = source
local xPlayer = ESX.GetPlayerFromId(source)
if xPlayer.get('money') >= Config.LicensePrice then
xPlayer.removeMoney(Config.LicensePrice)
TriggerEvent('esx_license:addLicense', _source, 'weapon', function ()
LoadLicenses(_source)
end)
else
TriggerClientEvent('esx:showNotification', _source, _U('not_enough'))
end
end)
ESX.RegisterServerCallback('esx_weashop:requestDBItems', function(source, cb)
MySQL.Async.fetchAll(