diff --git a/[examples]/test_vehicles/meta.xml b/[examples]/test_vehicles/meta.xml
new file mode 100644
index 0000000..25dc434
--- /dev/null
+++ b/[examples]/test_vehicles/meta.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/[examples]/test_vehicles/s_vehicles.lua b/[examples]/test_vehicles/s_vehicles.lua
new file mode 100644
index 0000000..11d9cd9
--- /dev/null
+++ b/[examples]/test_vehicles/s_vehicles.lua
@@ -0,0 +1,23 @@
+-- Loads newmodels functions, which allow usage of custom model IDs "as if they were normal IDs"
+loadstring(exports.newmodels_reborn:import())()
+
+-- Vehicle model, x,y,z, rx,ry,rz, interior,dimension
+local VEHICLE_SPAWNS = {
+ {525, -938.74, 1034.21, 23.59, 3.42, 2.85, 20.27, 0, 0},
+ {490, -941.95, 1043.03, 24.25, 355.90, 356.51, 199.00, 0, 0},
+ {-1, -951.79, 1069.05, 25.96, 356.28, 356.34, 204.01, 0, 0},
+ {-5, -944.88, 1051.90, 24.84, 355.97, 356.23, 198.86, 0, 0},
+}
+
+local function createVehicles()
+ for i, data in ipairs(VEHICLE_SPAWNS) do
+ local model, x, y, z, rx, ry, rz, interior, dimension = unpack(data)
+ local vehicle = createVehicle(model, x, y, z, rx, ry, rz)
+ if vehicle then
+ setElementInterior(vehicle, interior)
+ setElementDimension(vehicle, dimension)
+ end
+ print("#" .. i .. " - Created vehicle with ID " .. model .. " at " .. x .. ", " .. y .. ", " .. z)
+ end
+end
+addEventHandler("onResourceStart", resourceRoot, createVehicles)
diff --git a/newmodels_reborn/scripts/optional/debug/c_debug.lua b/newmodels_reborn/scripts/optional/debug/c_debug.lua
index d920daf..7c8081d 100644
--- a/newmodels_reborn/scripts/optional/debug/c_debug.lua
+++ b/newmodels_reborn/scripts/optional/debug/c_debug.lua
@@ -94,14 +94,20 @@ local function drawDebug()
end
end
+local function handleElementDestroyed()
+ streamedElements[source] = nil
+end
+
local function toggleDebugView(cmd)
if not enabled then
if not (debugTimer) or (not isTimer(debugTimer)) then debugTimer = setTimer(updateDebugViewInfo, 1000, 0) end
addEventHandler("onClientRender", root, drawDebug, false)
+ addEventHandler("onClientElementDestroy", root, handleElementDestroyed)
else
if debugTimer and isTimer(debugTimer) then killTimer(debugTimer); debugTimer = nil end
streamedElements = {}
removeEventHandler("onClientRender", root, drawDebug)
+ removeEventHandler("onClientElementDestroy", root, handleElementDestroyed)
end
enabled = not enabled
outputChatBox(cmd .. " => " .. tostring(enabled))