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
+32 -14
View File
@@ -29,23 +29,19 @@ Citizen.CreateThread(function()
end
if IsControlJustReleased(0, Keys['E']) and not isProcessing then
isProcessing = true
ESX.ShowNotification(_U('weed_processingstarted'))
TriggerServerEvent('esx_drugs:processCannabis')
local timeLeft = Config.Delays.WeedProcessing / 1000
while timeLeft > 0 do
Citizen.Wait(1000)
timeLeft = timeLeft - 1
if GetDistanceBetweenCoords(GetEntityCoords(playerPed), Config.CircleZones.WeedProcessing.coords, false) > 4 then
ESX.ShowNotification(_U('weed_processingtoofar'))
TriggerServerEvent('esx_drugs:cancelProcessing')
break
end
if Config.LicenseEnable then
ESX.TriggerServerCallback('esx_license:checkLicense', function(hasProcessingLicense)
if hasProcessingLicense then
ProcessWeed()
else
OpenBuyLicenseMenu('weed_processing')
end
end, GetPlayerServerId(PlayerId()), 'weed_processing')
else
ProcessWeed()
end
isProcessing = false
end
else
Citizen.Wait(500)
@@ -53,6 +49,28 @@ Citizen.CreateThread(function()
end
end)
function ProcessWeed()
isProcessing = true
ESX.ShowNotification(_U('weed_processingstarted'))
TriggerServerEvent('esx_drugs:processCannabis')
local timeLeft = Config.Delays.WeedProcessing / 1000
local playerPed = PlayerPedId()
while timeLeft > 0 do
Citizen.Wait(1000)
timeLeft = timeLeft - 1
if GetDistanceBetweenCoords(GetEntityCoords(playerPed), Config.CircleZones.WeedProcessing.coords, false) > 4 then
ESX.ShowNotification(_U('weed_processingtoofar'))
TriggerServerEvent('esx_drugs:cancelProcessing')
break
end
end
isProcessing = false
end
Citizen.CreateThread(function()
while true do
Citizen.Wait(10)