From 045f3ac877efe2eb4023253c8562222226abdd77 Mon Sep 17 00:00:00 2001 From: Proddy Date: Wed, 3 Jul 2024 19:39:25 +0100 Subject: [PATCH] Fixed `BonusVehicles` not cleaning up on level swap --- .../Resources/Modules/Vehicles/BonusVehicles.lua | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Randomiser/Resources/Modules/Vehicles/BonusVehicles.lua b/Randomiser/Resources/Modules/Vehicles/BonusVehicles.lua index d94d399..4b6241f 100644 --- a/Randomiser/Resources/Modules/Vehicles/BonusVehicles.lua +++ b/Randomiser/Resources/Modules/Vehicles/BonusVehicles.lua @@ -23,7 +23,9 @@ local BonusVehicleP3D local BonusVehicleCON local function ReplaceCar(Path, P3DFile) - RandomBonusVehicles.Handlers.P3D[3] = nil + for i=3,#RandomBonusVehicles.Handlers.P3D do + RandomBonusVehicles.Handlers.P3D[i] = nil + end local ReplaceP3D = P3D.P3DFile(BonusVehicleP3D) @@ -64,4 +66,13 @@ end RandomBonusVehicles:AddP3DHandler("art/l?r*.p3d", FindBonusVehicle) RandomBonusVehicles:AddP3DHandler("art/l?z*.p3d", FindBonusVehicle) +RandomBonusVehicles:AddLevelHandler(function() + for i=3,#RandomBonusVehicles.Handlers.P3D do + RandomBonusVehicles.Handlers.P3D[i] = nil + end + RandomBonusVehicles.Handlers.CON = {} + + return false +end) + return RandomBonusVehicles \ No newline at end of file