Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coke & Meth Processing Updates #12

Merged
merged 7 commits into from
Mar 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
190 changes: 169 additions & 21 deletions README.md

Large diffs are not rendered by default.

Binary file added assets/qb-inventory-images/cocainebaggy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/qb-inventory-images/coke_brick.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/qb-inventory-images/coke_small_brick.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/qb-inventory-images/finescale.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/qb-inventory-images/keya.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/qb-inventory-images/keyb.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/qb-inventory-images/keyc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
326 changes: 302 additions & 24 deletions client/coke.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local QBCore = exports['qb-core']:GetCoreObject()

local spawnedCocaLeaf = 0
local CocaPlants = {}
local isPickingUp, isProcessing = false, false
local isPickingUp, isProcessing, CWarehouse = false, false, false


Citizen.CreateThread(function()
Expand All @@ -18,41 +18,181 @@ Citizen.CreateThread(function()
end
end
end)
--[[
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
local playerPed = PlayerPedId()
local coords = GetEntityCoords(playerPed)

if GetDistanceBetweenCoords(coords, Config.CircleZones.CokeProcessing.coords, true) < 2 then
if not isProcessing then
local pos = GetEntityCoords(PlayerPedId())
QBCore.Functions.DrawText3D(pos.x, pos.y, pos.z, "~g~E~w~ - Process cocaine leaves")
end
RegisterNetEvent('qb-drugprocessing:ProcessCocaFarm')
AddEventHandler('qb-drugprocessing:ProcessCocaFarm', function()
local coords = GetEntityCoords(PlayerPedId(source))

if GetDistanceBetweenCoords(coords, Config.CircleZones.CokeProcessing.coords, true) < 5 then
if not isProcessing then
QBCore.Functions.TriggerCallback('QBCore:HasItem', function(result)
if result then
print('You have this item SA')
hasitem1 = true
else
QBCore.Functions.Notify('You lack the correct item...', 'error')
end
end, 'coca_leaf')
Citizen.Wait(1000) -- BUFFER
QBCore.Functions.TriggerCallback('QBCore:HasItem', function(result)
if result and hasitem1 then
print('You have this item HA')
ProcessCoke()
else
QBCore.Functions.Notify('You lack the correct item...', 'error')
end
end, 'trimming_scissors')
end
end
end)

if IsControlJustReleased(0, 38) and not isProcessing then
RegisterNetEvent('qb-drugprocessing:ProcessCocaPowder')
AddEventHandler('qb-drugprocessing:ProcessCocaPowder', function()
local coords = GetEntityCoords(PlayerPedId(source))
local amount = 10
local amount2 = 5

if GetDistanceBetweenCoords(coords, Config.CircleZones.CokePowder.coords, true) < 5 then
if not isProcessing then
QBCore.Functions.TriggerCallback('QBCore:HasItem', function(result)
if result then
print('You have this item SA')
hasitem1 = true
end
end, 'coke', 10)
Citizen.Wait(1000)
if hasitem1 == true then
QBCore.Functions.TriggerCallback('QBCore:HasItem', function(result)
if result then
ProcessCoke()
else
QBCore.Functions.Notify('You lack cocaine leaves', 'error')
print('You have this item SA')
hasitem2 = true
end
end, 'coca_leaf')
end, 'bakingsoda', 5)
Citizen.Wait(1000) -- BUFFER
if hasitem2 == true then
QBCore.Functions.TriggerCallback('QBCore:HasItem', function(result)
if result and hasitem2 then
print('You have this item HA')
CutCokePowder()
hasitem1 = false
hasitem2 = false
end
end, 'finescale')
else
QBCore.Functions.Notify('You need ' ..amount2.. ' Baking Soda' , 'error')
Citizen.Wait(1000)
QBCore.Functions.Notify('Get The Right Items and Come Back', 'error')
end
else
QBCore.Functions.Notify('You need ' ..amount.. ' Piles of Cocaine' , 'error')
Citizen.Wait(1000)
QBCore.Functions.Notify('Get The Right Items and Come Back', 'error')
end
end
else
QBCore.Functions.Notify('You are already processing something', 'error')
end
end)

RegisterNetEvent('qb-drugprocessing:ProcessBricks')
AddEventHandler('qb-drugprocessing:ProcessBricks', function()
local coords = GetEntityCoords(PlayerPedId(source))
local amount = 4

if GetDistanceBetweenCoords(coords, Config.CircleZones.CokeBrick.coords, true) < 5 then
if not isProcessing then
QBCore.Functions.TriggerCallback('QBCore:HasItem', function(result)
if result then
print('You have this item SA')
hasitem1 = true
end
end, 'coke_small_brick', 4)
Citizen.Wait(1000)
if hasitem1 == true then
QBCore.Functions.TriggerCallback('QBCore:HasItem', function(result)
if result and hasitem1 then
print('You have this item HA')
ProcessBricks()
hasitem1 = false
end
end, 'finescale')
else
QBCore.Functions.Notify('You need ' ..amount.. ' Small Bricks' , 'error')
Citizen.Wait(1000)
QBCore.Functions.Notify('Get The Right Items and Come Back', 'error')
end
else
Citizen.Wait(500)
end
else
QBCore.Functions.Notify('You are already processing something', 'error')
end
end)

RegisterNetEvent('qb-drugprocessing:EnterCWarehouse')
AddEventHandler('qb-drugprocessing:EnterCWarehouse', function()
local ped = PlayerPedId()
local pos = GetEntityCoords(ped)
local dist = #(pos - vector3(Config.CokeLab["enter"].coords.x, Config.CokeLab["enter"].coords.y, Config.CokeLab["enter"].coords.z))
if dist < 2 then
QBCore.Functions.TriggerCallback('QBCore:HasItem', function(result)
if result then
print('You have the key')
EnterCWarehouse()
print('Entering Warehouse')
else
print('No Key Stupid')
QBCore.Functions.Notify('You lack the required items', 'error')
end
end, 'cocainekey')
end
end)]]
end)

RegisterNetEvent('qb-drugprocessing:ExitCWarehouse')
AddEventHandler('qb-drugprocessing:ExitCWarehouse', function()
local ped = PlayerPedId()
local pos = GetEntityCoords(ped)
local dist = #(pos - vector3(Config.CokeLab["exit"].coords.x, Config.CokeLab["exit"].coords.y, Config.CokeLab["exit"].coords.z))
if dist < 2 then
ExitCWarehouse()
print('Exiting Warehouse')
end
end)

function EnterCWarehouse()
local ped = PlayerPedId()
OpenDoorAnimation()
CWarehouse = true
Citizen.Wait(500)
DoScreenFadeOut(250)
Citizen.Wait(250)
SetEntityCoords(ped, Config.CokeLab["exit"].coords.x, Config.CokeLab["exit"].coords.y, Config.CokeLab["exit"].coords.z - 0.98)
SetEntityHeading(ped, Config.CokeLab["exit"].coords.w)
Citizen.Wait(1000)
DoScreenFadeIn(250)
end

function ExitCWarehouse()
local ped = PlayerPedId()
OpenDoorAnimation()
CWarehouse = true
Citizen.Wait(500)
DoScreenFadeOut(250)
Citizen.Wait(250)
SetEntityCoords(ped, Config.CokeLab["enter"].coords.x, Config.CokeLab["enter"].coords.y, Config.CokeLab["enter"].coords.z - 0.98)
SetEntityHeading(ped, Config.CokeLab["enter"].coords.w)
Citizen.Wait(1000)
DoScreenFadeIn(250)
CWarehouse = false
end



function ProcessCoke()
isProcessing = true
local playerPed = PlayerPedId()

TaskStartScenarioInPlace(playerPed, "PROP_HUMAN_PARKING_METER", 0, true)

QBCore.Functions.Progressbar("search_register", "Processing cocaine...", 15000, false, true, {
QBCore.Functions.Progressbar("search_register", "Processing Leaves...", 15000, false, true, {
disableMovement = true,
disableCarMovement = true,
disableMouse = false,
Expand All @@ -75,11 +215,122 @@ function ProcessCoke()
end, function()
ClearPedTasks(PlayerPedId())
end)
isProcessing = false
end

function CutCokePowder()
isProcessing = true
local playerPed = PlayerPedId()

TaskStartScenarioInPlace(playerPed, "PROP_HUMAN_PARKING_METER", 0, true)

QBCore.Functions.Progressbar("search_register", "Cutting Cocaine...", 15000, false, true, {
disableMovement = true,
disableCarMovement = true,
disableMouse = false,
disableCombat = true,
}, {}, {}, {}, function()
TriggerServerEvent('qb-drugtrafficking:processCocaPowder')

local timeLeft = Config.Delays.CokeProcessing / 1000

while timeLeft > 0 do
Citizen.Wait(1000)
timeLeft = timeLeft - 1

if GetDistanceBetweenCoords(GetEntityCoords(playerPed), Config.CircleZones.CokeProcessing.coords, false) > 4 then
TriggerServerEvent('qb-drugtrafficking:cancelProcessing')
break
end
end
ClearPedTasks(PlayerPedId())
end, function()
ClearPedTasks(PlayerPedId())
end)

isProcessing = false
end

Citizen.CreateThread(function()
function ProcessBricks()
isProcessing = true
local playerPed = PlayerPedId()

TaskStartScenarioInPlace(playerPed, "PROP_HUMAN_PARKING_METER", 0, true)

QBCore.Functions.Progressbar("search_register", "Bricking Up Cocaine...", 15000, false, true, {
disableMovement = true,
disableCarMovement = true,
disableMouse = false,
disableCombat = true,
}, {}, {}, {}, function()
TriggerServerEvent('qb-drugtrafficking:processCocaBrick')

local timeLeft = Config.Delays.CokeProcessing / 1000

while timeLeft > 0 do
Citizen.Wait(1000)
timeLeft = timeLeft - 1

if GetDistanceBetweenCoords(GetEntityCoords(playerPed), Config.CircleZones.CokeBrick.coords, false) > 4 then
TriggerServerEvent('qb-drugtrafficking:cancelProcessing')
break
end
end
ClearPedTasks(PlayerPedId())
end, function()
ClearPedTasks(PlayerPedId())
end)

isProcessing = false
end


RegisterNetEvent('qb-drugprocessing:pickCocaLeaves')
AddEventHandler('qb-drugprocessing:pickCocaLeaves', function()
local playerPed = PlayerPedId()
local coords = GetEntityCoords(playerPed)
local nearbyObject, nearbyID

for i=1, #CocaPlants, 1 do
if GetDistanceBetweenCoords(coords, GetEntityCoords(CocaPlants[i]), false) < 1 then
nearbyObject, nearbyID = CocaPlants[i], i
end
end

if nearbyObject and IsPedOnFoot(playerPed) then

if not isPickingUp then
isPickingUp = true
TaskStartScenarioInPlace(playerPed, 'world_human_gardener_plant', 0, false)

QBCore.Functions.Progressbar("search_register", "Picking cocaine leaves..", 10000, false, true, {
disableMovement = true,
disableCarMovement = true,
disableMouse = false,
disableCombat = true,
}, {}, {}, {}, function() -- Done
ClearPedTasks(PlayerPedId())
SetEntityAsMissionEntity(nearbyObject, false, true)
DeleteObject(nearbyObject)

table.remove(CocaPlants, nearbyID)
spawnedCocaLeaf = spawnedCocaLeaf - 1

TriggerServerEvent('qb-drugtrafficking:pickedUpCocaLeaf')

end, function()
ClearPedTasks(PlayerPedId())
end)

isPickingUp = false
end
else
Citizen.Wait(500)
end

end)

--[[Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
local playerPed = PlayerPedId()
Expand Down Expand Up @@ -127,7 +378,7 @@ Citizen.CreateThread(function()
Citizen.Wait(500)
end
end
end)
end)]]--

AddEventHandler('onResourceStop', function(resource)
if resource == GetCurrentResourceName() then
Expand Down Expand Up @@ -213,3 +464,30 @@ function GetCoordZCoke(x, y)

return 77
end

function LoadAnimationDict(dict)
RequestAnimDict(dict)
while not HasAnimDictLoaded(dict) do
RequestAnimDict(dict)
Citizen.Wait(1)
end
end

function OpenDoorAnimation()
local ped = PlayerPedId()
LoadAnimationDict("anim@heists@keycard@")
TaskPlayAnim(ped, "anim@heists@keycard@", "exit", 5.0, 1.0, -1, 16, 0, 0, 0, 0)
Citizen.Wait(400)
ClearPedTasks(ped)
end


RegisterCommand('propfix', function()
for k, v in pairs(GetGamePool('CObject')) do
if IsEntityAttachedToEntity(PlayerPedId(), v) then
SetEntityAsMissionEntity(v, true, true)
DeleteObject(v)
DeleteEntity(v)
end
end
end)
Loading