diff --git a/client/chemicals.lua b/client/chemicals.lua index 3273c01..8ea989f 100644 --- a/client/chemicals.lua +++ b/client/chemicals.lua @@ -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 @@ -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() @@ -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 @@ -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') diff --git a/client/coke.lua b/client/coke.lua index 1504624..049caf0 100644 --- a/client/coke.lua +++ b/client/coke.lua @@ -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 @@ -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 @@ -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 @@ -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, @@ -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') @@ -339,7 +340,7 @@ 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 @@ -347,7 +348,7 @@ AddEventHandler('onResourceStop', function(resource) 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) diff --git a/client/heroin.lua b/client/heroin.lua index d0ce1dc..db47563 100644 --- a/client/heroin.lua +++ b/client/heroin.lua @@ -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 @@ -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() @@ -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 @@ -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') @@ -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 diff --git a/client/hydrochloricacid.lua b/client/hydrochloricacid.lua index 091f458..fb20c7a 100644 --- a/client/hydrochloricacid.lua +++ b/client/hydrochloricacid.lua @@ -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 @@ -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() @@ -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') @@ -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 diff --git a/client/sodiumhydroxide.lua b/client/sodiumhydroxide.lua index 4502fa1..c0730a1 100644 --- a/client/sodiumhydroxide.lua +++ b/client/sodiumhydroxide.lua @@ -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 @@ -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 @@ -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 @@ -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') @@ -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 diff --git a/client/sulfuricacid.lua b/client/sulfuricacid.lua index 0e9a29f..ff11737 100644 --- a/client/sulfuricacid.lua +++ b/client/sulfuricacid.lua @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/client/weed.lua b/client/weed.lua index 1d2e91b..057b8df 100644 --- a/client/weed.lua +++ b/client/weed.lua @@ -6,7 +6,7 @@ local QBCore = exports['qb-core']:GetCoreObject() local function ValidateWeedCoord(plantCoord) local validate = true if spawnedWeeds > 0 then - for k, v in pairs(weedPlants) do + for _, v in pairs(weedPlants) do if #(plantCoord - GetEntityCoords(v)) < 5 then validate = false end @@ -59,19 +59,21 @@ local function GenerateWeedCoords() end local function SpawnWeedPlants() + local model = `mw_weed_plant` while spawnedWeeds < 15 do Wait(0) local weedCoords = GenerateWeedCoords() - RequestModel(`mw_weed_plant`) - while not HasModelLoaded(`mw_weed_plant`) do + RequestModel(model) + while not HasModelLoaded(model) do Wait(100) end - local obj = CreateObject(`mw_weed_plant`, 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(weedPlants, obj) + weedPlants[#weedPlants+1] = obj spawnedWeeds += 1 end + SetModelAsNoLongerNeeded(model) end local function RollJoint() @@ -144,7 +146,7 @@ RegisterNetEvent("ps-drugprocessing:pickWeed", function() local nearbyObject, nearbyID for i=1, #weedPlants, 1 do - if GetDistanceBetweenCoords(coords, GetEntityCoords(weedPlants[i]), false) < 2 then + if #(coords - GetEntityCoords(weedPlants[i])) < 2 then nearbyObject, nearbyID = weedPlants[i], i end end @@ -162,7 +164,7 @@ RegisterNetEvent("ps-drugprocessing:pickWeed", function() ClearPedTasks(PlayerPedId()) SetEntityAsMissionEntity(nearbyObject, false, true) DeleteObject(nearbyObject) - table.remove(weedPlants, nearbyID) + weedPlants[nearbyID] = nil spawnedWeeds -= 1 TriggerServerEvent('ps-drugprocessing:pickedUpCannabis') isPickingUp = false @@ -176,7 +178,7 @@ end) AddEventHandler('onResourceStop', function(resource) if resource == GetCurrentResourceName() then - for k, v in pairs(weedPlants) do + for _, v in pairs(weedPlants) do SetEntityAsMissionEntity(v, false, true) DeleteObject(v) end