Implemented processing license

This commit is contained in:
ElPumpo
2018-12-08 13:30:26 +01:00
parent 6291156b32
commit 7974aea5a1
7 changed files with 130 additions and 24 deletions
+20
View File
@@ -32,6 +32,26 @@ AddEventHandler('esx_drugs:sellDrug', function(itemName, amount)
TriggerClientEvent('esx:showNotification', source, _U('dealer_sold', amount, xItem.label, ESX.Math.GroupDigits(price)))
end)
ESX.RegisterServerCallback('esx_drugs:buyLicense', function(source, cb, licenseName)
local xPlayer = ESX.GetPlayerFromId(source)
local license = Config.LicensePrices[licenseName]
if license == nil then
print(('esx_drugs: %s attempted to buy an invalid license!'):format(xPlayer.identifier))
cb(false)
end
if xPlayer.getMoney() >= license.price then
xPlayer.removeMoney(license.price)
TriggerEvent('esx_license:addLicense', source, licenseName, function()
cb(true)
end)
else
cb(false)
end
end)
RegisterServerEvent('esx_drugs:pickedUpCannabis')
AddEventHandler('esx_drugs:pickedUpCannabis', function()
local xPlayer = ESX.GetPlayerFromId(source)