Skip to content
This repository was archived by the owner on Feb 6, 2026. It is now read-only.

Commit 304744f

Browse files
Merge pull request #106 from TehSteel/main
Small cleanup.
2 parents aa1e867 + 4c85074 commit 304744f

7 files changed

Lines changed: 69 additions & 56 deletions

File tree

client/chemicals.lua

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ RegisterNetEvent('ps-drugprocessing:chemicalmenu', createChemicalMenu)
5454
local function ValidatechemicalsCoord(plantCoord)
5555
local validate = true
5656
if SpawnedChemicals > 0 then
57-
for k, v in pairs(Chemicals) do
57+
for _, v in pairs(Chemicals) do
5858
if #(plantCoord-GetEntityCoords(v)) < 5 then
5959
validate = false
6060
end
@@ -106,19 +106,21 @@ local function GeneratechemicalsCoords()
106106
end
107107

108108
local function SpawnChemicals()
109+
local model = `mw_chemical_barrel`
109110
while SpawnedChemicals < 10 do
110111
Wait(0)
111112
local chemicalsCoords = GeneratechemicalsCoords()
112-
RequestModel(`mw_chemical_barrel`)
113-
while not HasModelLoaded(`mw_chemical_barrel`) do
113+
RequestModel(model)
114+
while not HasModelLoaded(model) do
114115
Wait(100)
115116
end
116-
local obj = CreateObject(`mw_chemical_barrel`, chemicalsCoords.x, chemicalsCoords.y, chemicalsCoords.z, false, true, false)
117+
local obj = CreateObject(model, chemicalsCoords.x, chemicalsCoords.y, chemicalsCoords.z, false, true, false)
117118
PlaceObjectOnGroundProperly(obj)
118119
FreezeEntityPosition(obj, true)
119-
table.insert(Chemicals, obj)
120+
Chemicals[#Chemicals+1] = obj
120121
SpawnedChemicals += 1
121122
end
123+
SetModelAsNoLongerNeeded(model)
122124
end
123125

124126
local function process_hydrochloric_acid()
@@ -244,7 +246,7 @@ end
244246

245247
AddEventHandler('onResourceStop', function(resource)
246248
if resource == GetCurrentResourceName() then
247-
for k, v in pairs(Chemicals) do
249+
for _, v in pairs(Chemicals) do
248250
SetEntityAsMissionEntity(v, false, true)
249251
DeleteObject(v)
250252
end
@@ -316,7 +318,7 @@ RegisterNetEvent("ps-drugprocessing:pickChemicals", function()
316318
SetEntityAsMissionEntity(nearbyObject, false, true)
317319
DeleteObject(nearbyObject)
318320

319-
table.remove(Chemicals, nearbyID)
321+
Chemicals[nearbyID] = nil
320322
SpawnedChemicals -= 1
321323

322324
TriggerServerEvent('ps-drugprocessing:pickedUpChemicals')

client/coke.lua

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ end
8282
local function ValidateCocaLeafCoord(plantCoord)
8383
local validate = true
8484
if spawnedCocaLeaf > 0 then
85-
for k, v in pairs(CocaPlants) do
85+
for _, v in pairs(CocaPlants) do
8686
if #(plantCoord - GetEntityCoords(v)) < 5 then
8787
validate = false
8888
end
@@ -135,19 +135,21 @@ local function GenerateCocaLeafCoords()
135135
end
136136

137137
local function SpawnCocaPlants()
138+
local model = `h4_prop_bush_cocaplant_01`
138139
while spawnedCocaLeaf < 15 do
139140
Wait(0)
140141
local weedCoords = GenerateCocaLeafCoords()
141-
RequestModel(`h4_prop_bush_cocaplant_01`)
142-
while not HasModelLoaded(`h4_prop_bush_cocaplant_01`) do
142+
RequestModel(model)
143+
while not HasModelLoaded(model) do
143144
Wait(100)
144145
end
145-
local obj = CreateObject(`h4_prop_bush_cocaplant_01`, weedCoords.x, weedCoords.y, weedCoords.z, false, true, false)
146+
local obj = CreateObject(model, weedCoords.x, weedCoords.y, weedCoords.z, false, true, false)
146147
PlaceObjectOnGroundProperly(obj)
147148
FreezeEntityPosition(obj, true)
148-
table.insert(CocaPlants, obj)
149+
CocaPlants[#CocaPlants+1] = obj
149150
spawnedCocaLeaf += 1
150151
end
152+
SetModelAsNoLongerNeeded(model)
151153
end
152154

153155

@@ -303,7 +305,7 @@ RegisterNetEvent('ps-drugprocessing:pickCocaLeaves', function()
303305
local nearbyObject, nearbyID
304306

305307
for i=1, #CocaPlants, 1 do
306-
if GetDistanceBetweenCoords(coords, GetEntityCoords(CocaPlants[i]), false) < 2 then
308+
if #(coords - GetEntityCoords(CocaPlants[i])) < 2 then
307309
nearbyObject, nearbyID = CocaPlants[i], i
308310
end
309311
end
@@ -312,7 +314,6 @@ RegisterNetEvent('ps-drugprocessing:pickCocaLeaves', function()
312314
if not isPickingUp then
313315
isPickingUp = true
314316
TaskStartScenarioInPlace(playerPed, 'world_human_gardener_plant', 0, false)
315-
316317
QBCore.Functions.Progressbar("search_register", Lang:t("progressbar.collecting"), 10000, false, true, {
317318
disableMovement = true,
318319
disableCarMovement = true,
@@ -323,7 +324,7 @@ RegisterNetEvent('ps-drugprocessing:pickCocaLeaves', function()
323324
SetEntityAsMissionEntity(nearbyObject, false, true)
324325
DeleteObject(nearbyObject)
325326

326-
table.remove(CocaPlants, nearbyID)
327+
CocaPlants[nearbyID] = nil
327328
spawnedCocaLeaf = spawnedCocaLeaf - 1
328329

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

340341
AddEventHandler('onResourceStop', function(resource)
341342
if resource == GetCurrentResourceName() then
342-
for k, v in pairs(CocaPlants) do
343+
for _, v in pairs(CocaPlants) do
343344
SetEntityAsMissionEntity(v, false, true)
344345
DeleteObject(v)
345346
end
346347
end
347348
end)
348349

349350
RegisterCommand('propfix', function()
350-
for k, v in pairs(GetGamePool('CObject')) do
351+
for _, v in pairs(GetGamePool('CObject')) do
351352
if IsEntityAttachedToEntity(PlayerPedId(), v) then
352353
SetEntityAsMissionEntity(v, true, true)
353354
DeleteObject(v)

client/heroin.lua

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ local QBCore = exports['qb-core']:GetCoreObject()
66
local function ValidateHeroinCoord(plantCoord)
77
local validate = true
88
if spawnedPoppys > 0 then
9-
for k, v in pairs(PoppyPlants) do
9+
for _, v in pairs(PoppyPlants) do
1010
if #(plantCoord - GetEntityCoords(v)) < 5 then
1111
validate = false
1212
end
@@ -59,19 +59,21 @@ local function GenerateHeroinCoords()
5959
end
6060

6161
local function SpawnPoppyPlants()
62+
local model = `prop_plant_01b`
6263
while spawnedPoppys < 15 do
6364
Wait(0)
6465
local heroinCoords = GenerateHeroinCoords()
65-
RequestModel(`prop_plant_01b`)
66-
while not HasModelLoaded(`prop_plant_01b`) do
66+
RequestModel(model)
67+
while not HasModelLoaded(model) do
6768
Wait(100)
6869
end
69-
local obj = CreateObject(`prop_plant_01b`, heroinCoords.x, heroinCoords.y, heroinCoords.z, false, true, false)
70+
local obj = CreateObject(model, heroinCoords.x, heroinCoords.y, heroinCoords.z, false, true, false)
7071
PlaceObjectOnGroundProperly(obj)
7172
FreezeEntityPosition(obj, true)
72-
table.insert(PoppyPlants, obj)
73+
PoppyPlants[#PoppyPlants+1] = obj
7374
spawnedPoppys += 1
7475
end
76+
SetModelAsNoLongerNeeded(model)
7577
end
7678

7779
local function ProcessHeroin()
@@ -138,7 +140,7 @@ RegisterNetEvent("ps-drugprocessing:pickHeroin", function()
138140
local nearbyObject, nearbyID
139141

140142
for i=1, #PoppyPlants, 1 do
141-
if GetDistanceBetweenCoords(coords, GetEntityCoords(PoppyPlants[i]), false) < 2 then
143+
if #(coords - GetEntityCoords(PoppyPlants[i])) < 2 then
142144
nearbyObject, nearbyID = PoppyPlants[i], i
143145
end
144146
end
@@ -156,7 +158,7 @@ RegisterNetEvent("ps-drugprocessing:pickHeroin", function()
156158
SetEntityAsMissionEntity(nearbyObject, false, true)
157159
DeleteObject(nearbyObject)
158160

159-
table.remove(PoppyPlants, nearbyID)
161+
PoppyPlants[nearbyID] = nil
160162
spawnedPoppys -= 1
161163

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

172174
AddEventHandler('onResourceStop', function(resource)
173175
if resource == GetCurrentResourceName() then
174-
for k, v in pairs(PoppyPlants) do
176+
for _, v in pairs(PoppyPlants) do
175177
SetEntityAsMissionEntity(v, false, true)
176178
DeleteObject(v)
177179
end

client/hydrochloricacid.lua

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ local QBCore = exports['qb-core']:GetCoreObject()
77
local function ValidateHydrochloricAcidCoord(plantCoord)
88
local validate = true
99
if spawnedHydrochloricAcidBarrels > 0 then
10-
for k, v in pairs(HydrochloricAcidBarrels) do
10+
for _, v in pairs(HydrochloricAcidBarrels) do
1111
if #(plantCoord-GetEntityCoords(v)) < 5 then
1212
validate = false
1313
end
@@ -60,19 +60,21 @@ local function GenerateHydrochloricAcidCoords()
6060
end
6161

6262
local function SpawnHydrochloricAcidBarrels()
63+
local model = `mw_hydro_barrel`
6364
while spawnedHydrochloricAcidBarrels < 5 do
6465
Wait(0)
6566
local weedCoords = GenerateHydrochloricAcidCoords()
66-
RequestModel(`mw_hydro_barrel`)
67-
while not HasModelLoaded(`mw_hydro_barrel`) do
67+
RequestModel(model)
68+
while not HasModelLoaded(model) do
6869
Wait(100)
6970
end
70-
local obj = CreateObject(`mw_hydro_barrel`, weedCoords.x, weedCoords.y, weedCoords.z, false, true, false)
71+
local obj = CreateObject(model, weedCoords.x, weedCoords.y, weedCoords.z, false, true, false)
7172
PlaceObjectOnGroundProperly(obj)
7273
FreezeEntityPosition(obj, true)
73-
table.insert(HydrochloricAcidBarrels, obj)
74+
HydrochloricAcidBarrels[#HydrochloricAcidBarrels+1] = obj
7475
spawnedHydrochloricAcidBarrels = spawnedHydrochloricAcidBarrels + 1
7576
end
77+
SetModelAsNoLongerNeeded(model)
7678
end
7779

7880
RegisterNetEvent("ps-drugprocessing:client:hydrochloricacid", function()
@@ -99,7 +101,7 @@ RegisterNetEvent("ps-drugprocessing:client:hydrochloricacid", function()
99101
SetEntityAsMissionEntity(nearbyObject, false, true)
100102
DeleteObject(nearbyObject)
101103

102-
table.remove(HydrochloricAcidBarrels, nearbyID)
104+
HydrochloricAcidBarrels[nearbyID] = nil
103105
spawnedHydrochloricAcidBarrels -= 1
104106

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

114116
AddEventHandler('onResourceStop', function(resource)
115117
if resource == GetCurrentResourceName() then
116-
for k, v in pairs(HydrochloricAcidBarrels) do
118+
for _, v in pairs(HydrochloricAcidBarrels) do
117119
SetEntityAsMissionEntity(v, false, true)
118120
DeleteObject(v)
119121
end

client/sodiumhydroxide.lua

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ local QBCore = exports['qb-core']:GetCoreObject()
66
local function ValidateSodiumHydroxideCoord(plantCoord)
77
local validate2 = true
88
if spawnedSodiumHydroxideBarrels > 0 then
9-
for k, v in pairs(SodiumHydroxideBarrels) do
9+
for _, v in pairs(SodiumHydroxideBarrels) do
1010
if #(plantCoord - GetEntityCoords(v)) < 5 then
1111
validate2 = false
1212
end
@@ -59,19 +59,21 @@ local function GenerateSodiumHydroxideCoords()
5959
end
6060

6161
local function SpawnSodiumHydroxideBarrels()
62+
local model = `mw_sodium_barrel`
6263
while spawnedSodiumHydroxideBarrels < 10 do
6364
Wait(0)
6465
local weedCoords2 = GenerateSodiumHydroxideCoords()
65-
RequestModel(`mw_sodium_barrel`)
66-
while not HasModelLoaded(`mw_sodium_barrel`) do
66+
RequestModel(model)
67+
while not HasModelLoaded(model) do
6768
Wait(100)
6869
end
69-
local obj = CreateObject(`mw_sodium_barrel`, weedCoords2.x, weedCoords2.y, weedCoords2.z, false, true, false)
70+
local obj = CreateObject(model, weedCoords2.x, weedCoords2.y, weedCoords2.z, false, true, false)
7071
PlaceObjectOnGroundProperly(obj)
7172
FreezeEntityPosition(obj, true)
72-
table.insert(SodiumHydroxideBarrels, obj)
73+
SodiumHydroxideBarrels[#SodiumHydroxideBarrels+1] = obj
7374
spawnedSodiumHydroxideBarrels = spawnedSodiumHydroxideBarrels + 1
7475
end
76+
SetModelAsNoLongerNeeded(model)
7577
end
7678

7779

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

8385
for i=1, #SodiumHydroxideBarrels, 1 do
84-
if GetDistanceBetweenCoords(coords, GetEntityCoords(SodiumHydroxideBarrels[i]), false) < 2 then
86+
if #(coords - GetEntityCoords(SodiumHydroxideBarrels[i])) < 2 then
8587
nearbyObject3, nearbyID3 = SodiumHydroxideBarrels[i], i
8688
end
8789
end
@@ -100,7 +102,7 @@ RegisterNetEvent("ps-drugprocessing:pickSodium", function()
100102
SetEntityAsMissionEntity(nearbyObject3, false, true)
101103
DeleteObject(nearbyObject3)
102104

103-
table.remove(SodiumHydroxideBarrels, nearbyID3)
105+
SodiumHydroxideBarrels[nearbyID3] = nil
104106
spawnedSodiumHydroxideBarrels -= 1
105107

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

116118
AddEventHandler('onResourceStop', function(resource)
117119
if resource == GetCurrentResourceName() then
118-
for k, v in pairs(SodiumHydroxideBarrels) do
120+
for _, v in pairs(SodiumHydroxideBarrels) do
119121
SetEntityAsMissionEntity(v, false, true)
120122
DeleteObject(v)
121123
end

client/sulfuricacid.lua

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ local QBCore = exports['qb-core']:GetCoreObject()
66
local function ValidateSulfuricAcidCoord(plantCoord)
77
local validate = true
88
if spawnedSulfuricAcidBarrels > 0 then
9-
for k, v in pairs(SulfuricAcidBarrels) do
9+
for _, v in pairs(SulfuricAcidBarrels) do
1010
if #(plantCoord - GetEntityCoords(v)) < 5 then
1111
validate = false
1212
end
@@ -59,19 +59,21 @@ local function GenerateSulfuricAcidCoords()
5959
end
6060

6161
local function SpawnSulfuricAcidBarrels()
62+
local model = `mw_sulfuric_barrel`
6263
while spawnedSulfuricAcidBarrels < 10 do
6364
Wait(0)
6465
local weedCoords = GenerateSulfuricAcidCoords()
65-
RequestModel(`mw_sulfuric_barrel`)
66-
while not HasModelLoaded(`mw_sulfuric_barrel`) do
66+
RequestModel(model)
67+
while not HasModelLoaded(model) do
6768
Wait(100)
6869
end
69-
local obj = CreateObject(`mw_sulfuric_barrel`, weedCoords.x, weedCoords.y, weedCoords.z, false, true, false)
70+
local obj = CreateObject(model, weedCoords.x, weedCoords.y, weedCoords.z, false, true, false)
7071
PlaceObjectOnGroundProperly(obj)
7172
FreezeEntityPosition(obj, true)
72-
table.insert(SulfuricAcidBarrels, obj)
73+
SulfuricAcidBarrels[#SulfuricAcidBarrels+1] = obj
7374
spawnedSulfuricAcidBarrels += 1
7475
end
76+
SetModelAsNoLongerNeeded(model)
7577
end
7678

7779

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

8385
for i=1, #SulfuricAcidBarrels, 1 do
84-
if GetDistanceBetweenCoords(coords, GetEntityCoords(SulfuricAcidBarrels[i]), false) < 2 then
86+
if #(coords - GetEntityCoords(SulfuricAcidBarrels[i])) < 2 then
8587
nearbyObject, nearbyID = SulfuricAcidBarrels[i], i
8688
end
8789
end
@@ -99,7 +101,7 @@ RegisterNetEvent("ps-drugprocessing:pickSulfuric", function()
99101
ClearPedTasks(PlayerPedId())
100102
SetEntityAsMissionEntity(nearbyObject, false, true)
101103
DeleteObject(nearbyObject)
102-
table.remove(SulfuricAcidBarrels, nearbyID)
104+
SulfuricAcidBarrels[nearbyID] = nil
103105
spawnedSulfuricAcidBarrels -= 1
104106
TriggerServerEvent('ps-drugprocessing:pickedUpSulfuricAcid')
105107
isPickingUp = false
@@ -113,7 +115,7 @@ end)
113115

114116
AddEventHandler('onResourceStop', function(resource)
115117
if resource == GetCurrentResourceName() then
116-
for k, v in pairs(SulfuricAcidBarrels) do
118+
for _, v in pairs(SulfuricAcidBarrels) do
117119
SetEntityAsMissionEntity(v, false, true)
118120
DeleteObject(v)
119121
end

0 commit comments

Comments
 (0)