Skip to content

Commit

Permalink
add test resource
Browse files Browse the repository at this point in the history
  • Loading branch information
Fernando-A-Rocha committed Aug 1, 2024
1 parent 8a9cd3d commit 95aadef
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
4 changes: 4 additions & 0 deletions [examples]/test_vehicles/meta.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<meta>
<include resource="newmodels_reborn" minversion="4.0.0"/>
<script src="s_vehicles.lua" type="server"/>
</meta>
23 changes: 23 additions & 0 deletions [examples]/test_vehicles/s_vehicles.lua
Original file line number Diff line number Diff line change
@@ -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)
6 changes: 6 additions & 0 deletions newmodels_reborn/scripts/optional/debug/c_debug.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 95aadef

Please sign in to comment.