Skip to content

Commit

Permalink
Merge pull request #106 from TehSteel/main
Browse files Browse the repository at this point in the history
Small cleanup.
  • Loading branch information
MonkeyWhisper authored Feb 8, 2023
2 parents aa1e867 + 4c85074 commit 304744f
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 56 deletions.
16 changes: 9 additions & 7 deletions client/chemicals.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ RegisterNetEvent('ps-drugprocessing:chemicalmenu', createChemicalMenu)
local function ValidatechemicalsCoord(plantCoord)
local validate = true
if SpawnedChemicals > 0 then
for k, v in pairs(Chemicals) do
for _, v in pairs(Chemicals) do
if #(plantCoord-GetEntityCoords(v)) < 5 then
validate = false
end
Expand Down Expand Up @@ -106,19 +106,21 @@ local function GeneratechemicalsCoords()
end

local function SpawnChemicals()
local model = `mw_chemical_barrel`
while SpawnedChemicals < 10 do
Wait(0)
local chemicalsCoords = GeneratechemicalsCoords()
RequestModel(`mw_chemical_barrel`)
while not HasModelLoaded(`mw_chemical_barrel`) do
RequestModel(model)
while not HasModelLoaded(model) do
Wait(100)
end
local obj = CreateObject(`mw_chemical_barrel`, chemicalsCoords.x, chemicalsCoords.y, chemicalsCoords.z, false, true, false)
local obj = CreateObject(model, chemicalsCoords.x, chemicalsCoords.y, chemicalsCoords.z, false, true, false)
PlaceObjectOnGroundProperly(obj)
FreezeEntityPosition(obj, true)
table.insert(Chemicals, obj)
Chemicals[#Chemicals+1] = obj
SpawnedChemicals += 1
end
SetModelAsNoLongerNeeded(model)
end

local function process_hydrochloric_acid()
Expand Down Expand Up @@ -244,7 +246,7 @@ end

AddEventHandler('onResourceStop', function(resource)
if resource == GetCurrentResourceName() then
for k, v in pairs(Chemicals) do
for _, v in pairs(Chemicals) do
SetEntityAsMissionEntity(v, false, true)
DeleteObject(v)
end
Expand Down Expand Up @@ -316,7 +318,7 @@ RegisterNetEvent("ps-drugprocessing:pickChemicals", function()
SetEntityAsMissionEntity(nearbyObject, false, true)
DeleteObject(nearbyObject)

table.remove(Chemicals, nearbyID)
Chemicals[nearbyID] = nil
SpawnedChemicals -= 1

TriggerServerEvent('ps-drugprocessing:pickedUpChemicals')
Expand Down
21 changes: 11 additions & 10 deletions client/coke.lua
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ end
local function ValidateCocaLeafCoord(plantCoord)
local validate = true
if spawnedCocaLeaf > 0 then
for k, v in pairs(CocaPlants) do
for _, v in pairs(CocaPlants) do
if #(plantCoord - GetEntityCoords(v)) < 5 then
validate = false
end
Expand Down Expand Up @@ -135,19 +135,21 @@ local function GenerateCocaLeafCoords()
end

local function SpawnCocaPlants()
local model = `h4_prop_bush_cocaplant_01`
while spawnedCocaLeaf < 15 do
Wait(0)
local weedCoords = GenerateCocaLeafCoords()
RequestModel(`h4_prop_bush_cocaplant_01`)
while not HasModelLoaded(`h4_prop_bush_cocaplant_01`) do
RequestModel(model)
while not HasModelLoaded(model) do
Wait(100)
end
local obj = CreateObject(`h4_prop_bush_cocaplant_01`, weedCoords.x, weedCoords.y, weedCoords.z, false, true, false)
local obj = CreateObject(model, weedCoords.x, weedCoords.y, weedCoords.z, false, true, false)
PlaceObjectOnGroundProperly(obj)
FreezeEntityPosition(obj, true)
table.insert(CocaPlants, obj)
CocaPlants[#CocaPlants+1] = obj
spawnedCocaLeaf += 1
end
SetModelAsNoLongerNeeded(model)
end


Expand Down Expand Up @@ -303,7 +305,7 @@ RegisterNetEvent('ps-drugprocessing:pickCocaLeaves', function()
local nearbyObject, nearbyID

for i=1, #CocaPlants, 1 do
if GetDistanceBetweenCoords(coords, GetEntityCoords(CocaPlants[i]), false) < 2 then
if #(coords - GetEntityCoords(CocaPlants[i])) < 2 then
nearbyObject, nearbyID = CocaPlants[i], i
end
end
Expand All @@ -312,7 +314,6 @@ RegisterNetEvent('ps-drugprocessing:pickCocaLeaves', function()
if not isPickingUp then
isPickingUp = true
TaskStartScenarioInPlace(playerPed, 'world_human_gardener_plant', 0, false)

QBCore.Functions.Progressbar("search_register", Lang:t("progressbar.collecting"), 10000, false, true, {
disableMovement = true,
disableCarMovement = true,
Expand All @@ -323,7 +324,7 @@ RegisterNetEvent('ps-drugprocessing:pickCocaLeaves', function()
SetEntityAsMissionEntity(nearbyObject, false, true)
DeleteObject(nearbyObject)

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

TriggerServerEvent('ps-drugprocessing:pickedUpCocaLeaf')
Expand All @@ -339,15 +340,15 @@ end)

AddEventHandler('onResourceStop', function(resource)
if resource == GetCurrentResourceName() then
for k, v in pairs(CocaPlants) do
for _, v in pairs(CocaPlants) do
SetEntityAsMissionEntity(v, false, true)
DeleteObject(v)
end
end
end)

RegisterCommand('propfix', function()
for k, v in pairs(GetGamePool('CObject')) do
for _, v in pairs(GetGamePool('CObject')) do
if IsEntityAttachedToEntity(PlayerPedId(), v) then
SetEntityAsMissionEntity(v, true, true)
DeleteObject(v)
Expand Down
18 changes: 10 additions & 8 deletions client/heroin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ local QBCore = exports['qb-core']:GetCoreObject()
local function ValidateHeroinCoord(plantCoord)
local validate = true
if spawnedPoppys > 0 then
for k, v in pairs(PoppyPlants) do
for _, v in pairs(PoppyPlants) do
if #(plantCoord - GetEntityCoords(v)) < 5 then
validate = false
end
Expand Down Expand Up @@ -59,19 +59,21 @@ local function GenerateHeroinCoords()
end

local function SpawnPoppyPlants()
local model = `prop_plant_01b`
while spawnedPoppys < 15 do
Wait(0)
local heroinCoords = GenerateHeroinCoords()
RequestModel(`prop_plant_01b`)
while not HasModelLoaded(`prop_plant_01b`) do
RequestModel(model)
while not HasModelLoaded(model) do
Wait(100)
end
local obj = CreateObject(`prop_plant_01b`, heroinCoords.x, heroinCoords.y, heroinCoords.z, false, true, false)
local obj = CreateObject(model, heroinCoords.x, heroinCoords.y, heroinCoords.z, false, true, false)
PlaceObjectOnGroundProperly(obj)
FreezeEntityPosition(obj, true)
table.insert(PoppyPlants, obj)
PoppyPlants[#PoppyPlants+1] = obj
spawnedPoppys += 1
end
SetModelAsNoLongerNeeded(model)
end

local function ProcessHeroin()
Expand Down Expand Up @@ -138,7 +140,7 @@ RegisterNetEvent("ps-drugprocessing:pickHeroin", function()
local nearbyObject, nearbyID

for i=1, #PoppyPlants, 1 do
if GetDistanceBetweenCoords(coords, GetEntityCoords(PoppyPlants[i]), false) < 2 then
if #(coords - GetEntityCoords(PoppyPlants[i])) < 2 then
nearbyObject, nearbyID = PoppyPlants[i], i
end
end
Expand All @@ -156,7 +158,7 @@ RegisterNetEvent("ps-drugprocessing:pickHeroin", function()
SetEntityAsMissionEntity(nearbyObject, false, true)
DeleteObject(nearbyObject)

table.remove(PoppyPlants, nearbyID)
PoppyPlants[nearbyID] = nil
spawnedPoppys -= 1

TriggerServerEvent('ps-drugprocessing:pickedUpPoppy')
Expand All @@ -171,7 +173,7 @@ end)

AddEventHandler('onResourceStop', function(resource)
if resource == GetCurrentResourceName() then
for k, v in pairs(PoppyPlants) do
for _, v in pairs(PoppyPlants) do
SetEntityAsMissionEntity(v, false, true)
DeleteObject(v)
end
Expand Down
16 changes: 9 additions & 7 deletions client/hydrochloricacid.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ local QBCore = exports['qb-core']:GetCoreObject()
local function ValidateHydrochloricAcidCoord(plantCoord)
local validate = true
if spawnedHydrochloricAcidBarrels > 0 then
for k, v in pairs(HydrochloricAcidBarrels) do
for _, v in pairs(HydrochloricAcidBarrels) do
if #(plantCoord-GetEntityCoords(v)) < 5 then
validate = false
end
Expand Down Expand Up @@ -60,19 +60,21 @@ local function GenerateHydrochloricAcidCoords()
end

local function SpawnHydrochloricAcidBarrels()
local model = `mw_hydro_barrel`
while spawnedHydrochloricAcidBarrels < 5 do
Wait(0)
local weedCoords = GenerateHydrochloricAcidCoords()
RequestModel(`mw_hydro_barrel`)
while not HasModelLoaded(`mw_hydro_barrel`) do
RequestModel(model)
while not HasModelLoaded(model) do
Wait(100)
end
local obj = CreateObject(`mw_hydro_barrel`, weedCoords.x, weedCoords.y, weedCoords.z, false, true, false)
local obj = CreateObject(model, weedCoords.x, weedCoords.y, weedCoords.z, false, true, false)
PlaceObjectOnGroundProperly(obj)
FreezeEntityPosition(obj, true)
table.insert(HydrochloricAcidBarrels, obj)
HydrochloricAcidBarrels[#HydrochloricAcidBarrels+1] = obj
spawnedHydrochloricAcidBarrels = spawnedHydrochloricAcidBarrels + 1
end
SetModelAsNoLongerNeeded(model)
end

RegisterNetEvent("ps-drugprocessing:client:hydrochloricacid", function()
Expand All @@ -99,7 +101,7 @@ RegisterNetEvent("ps-drugprocessing:client:hydrochloricacid", function()
SetEntityAsMissionEntity(nearbyObject, false, true)
DeleteObject(nearbyObject)

table.remove(HydrochloricAcidBarrels, nearbyID)
HydrochloricAcidBarrels[nearbyID] = nil
spawnedHydrochloricAcidBarrels -= 1

TriggerServerEvent('ps-drugprocessing:pickedUpHydrochloricAcid')
Expand All @@ -113,7 +115,7 @@ end)

AddEventHandler('onResourceStop', function(resource)
if resource == GetCurrentResourceName() then
for k, v in pairs(HydrochloricAcidBarrels) do
for _, v in pairs(HydrochloricAcidBarrels) do
SetEntityAsMissionEntity(v, false, true)
DeleteObject(v)
end
Expand Down
18 changes: 10 additions & 8 deletions client/sodiumhydroxide.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ local QBCore = exports['qb-core']:GetCoreObject()
local function ValidateSodiumHydroxideCoord(plantCoord)
local validate2 = true
if spawnedSodiumHydroxideBarrels > 0 then
for k, v in pairs(SodiumHydroxideBarrels) do
for _, v in pairs(SodiumHydroxideBarrels) do
if #(plantCoord - GetEntityCoords(v)) < 5 then
validate2 = false
end
Expand Down Expand Up @@ -59,19 +59,21 @@ local function GenerateSodiumHydroxideCoords()
end

local function SpawnSodiumHydroxideBarrels()
local model = `mw_sodium_barrel`
while spawnedSodiumHydroxideBarrels < 10 do
Wait(0)
local weedCoords2 = GenerateSodiumHydroxideCoords()
RequestModel(`mw_sodium_barrel`)
while not HasModelLoaded(`mw_sodium_barrel`) do
RequestModel(model)
while not HasModelLoaded(model) do
Wait(100)
end
local obj = CreateObject(`mw_sodium_barrel`, weedCoords2.x, weedCoords2.y, weedCoords2.z, false, true, false)
local obj = CreateObject(model, weedCoords2.x, weedCoords2.y, weedCoords2.z, false, true, false)
PlaceObjectOnGroundProperly(obj)
FreezeEntityPosition(obj, true)
table.insert(SodiumHydroxideBarrels, obj)
SodiumHydroxideBarrels[#SodiumHydroxideBarrels+1] = obj
spawnedSodiumHydroxideBarrels = spawnedSodiumHydroxideBarrels + 1
end
SetModelAsNoLongerNeeded(model)
end


Expand All @@ -81,7 +83,7 @@ RegisterNetEvent("ps-drugprocessing:pickSodium", function()
local nearbyObject3, nearbyID3

for i=1, #SodiumHydroxideBarrels, 1 do
if GetDistanceBetweenCoords(coords, GetEntityCoords(SodiumHydroxideBarrels[i]), false) < 2 then
if #(coords - GetEntityCoords(SodiumHydroxideBarrels[i])) < 2 then
nearbyObject3, nearbyID3 = SodiumHydroxideBarrels[i], i
end
end
Expand All @@ -100,7 +102,7 @@ RegisterNetEvent("ps-drugprocessing:pickSodium", function()
SetEntityAsMissionEntity(nearbyObject3, false, true)
DeleteObject(nearbyObject3)

table.remove(SodiumHydroxideBarrels, nearbyID3)
SodiumHydroxideBarrels[nearbyID3] = nil
spawnedSodiumHydroxideBarrels -= 1

TriggerServerEvent('ps-drugprocessing:pickedUpSodiumHydroxide')
Expand All @@ -115,7 +117,7 @@ end)

AddEventHandler('onResourceStop', function(resource)
if resource == GetCurrentResourceName() then
for k, v in pairs(SodiumHydroxideBarrels) do
for _, v in pairs(SodiumHydroxideBarrels) do
SetEntityAsMissionEntity(v, false, true)
DeleteObject(v)
end
Expand Down
18 changes: 10 additions & 8 deletions client/sulfuricacid.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ local QBCore = exports['qb-core']:GetCoreObject()
local function ValidateSulfuricAcidCoord(plantCoord)
local validate = true
if spawnedSulfuricAcidBarrels > 0 then
for k, v in pairs(SulfuricAcidBarrels) do
for _, v in pairs(SulfuricAcidBarrels) do
if #(plantCoord - GetEntityCoords(v)) < 5 then
validate = false
end
Expand Down Expand Up @@ -59,19 +59,21 @@ local function GenerateSulfuricAcidCoords()
end

local function SpawnSulfuricAcidBarrels()
local model = `mw_sulfuric_barrel`
while spawnedSulfuricAcidBarrels < 10 do
Wait(0)
local weedCoords = GenerateSulfuricAcidCoords()
RequestModel(`mw_sulfuric_barrel`)
while not HasModelLoaded(`mw_sulfuric_barrel`) do
RequestModel(model)
while not HasModelLoaded(model) do
Wait(100)
end
local obj = CreateObject(`mw_sulfuric_barrel`, weedCoords.x, weedCoords.y, weedCoords.z, false, true, false)
local obj = CreateObject(model, weedCoords.x, weedCoords.y, weedCoords.z, false, true, false)
PlaceObjectOnGroundProperly(obj)
FreezeEntityPosition(obj, true)
table.insert(SulfuricAcidBarrels, obj)
SulfuricAcidBarrels[#SulfuricAcidBarrels+1] = obj
spawnedSulfuricAcidBarrels += 1
end
SetModelAsNoLongerNeeded(model)
end


Expand All @@ -81,7 +83,7 @@ RegisterNetEvent("ps-drugprocessing:pickSulfuric", function()
local nearbyObject, nearbyID

for i=1, #SulfuricAcidBarrels, 1 do
if GetDistanceBetweenCoords(coords, GetEntityCoords(SulfuricAcidBarrels[i]), false) < 2 then
if #(coords - GetEntityCoords(SulfuricAcidBarrels[i])) < 2 then
nearbyObject, nearbyID = SulfuricAcidBarrels[i], i
end
end
Expand All @@ -99,7 +101,7 @@ RegisterNetEvent("ps-drugprocessing:pickSulfuric", function()
ClearPedTasks(PlayerPedId())
SetEntityAsMissionEntity(nearbyObject, false, true)
DeleteObject(nearbyObject)
table.remove(SulfuricAcidBarrels, nearbyID)
SulfuricAcidBarrels[nearbyID] = nil
spawnedSulfuricAcidBarrels -= 1
TriggerServerEvent('ps-drugprocessing:pickedUpSulfuricAcid')
isPickingUp = false
Expand All @@ -113,7 +115,7 @@ end)

AddEventHandler('onResourceStop', function(resource)
if resource == GetCurrentResourceName() then
for k, v in pairs(SulfuricAcidBarrels) do
for _, v in pairs(SulfuricAcidBarrels) do
SetEntityAsMissionEntity(v, false, true)
DeleteObject(v)
end
Expand Down
Loading

0 comments on commit 304744f

Please sign in to comment.