Skip to content

Commit

Permalink
Update client.lua
Browse files Browse the repository at this point in the history
  • Loading branch information
Fernando-A-Rocha committed Jul 6, 2024
1 parent a006080 commit 325d0f5
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions newmodels_reborn/core/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ local function applyElementCustomModel(element)
local loadedModel = loadedModels[customModel]
if not loadedModel then return end

local upgrades, handling
local upgrades, handling, paintjob
if getElementType(element) == "vehicle" then
upgrades = getVehicleUpgrades(element)
handling = getVehicleHandling(element)
paintjob = getVehiclePaintjob(element)
end

_setElementModel(element, loadedModel.id)
Expand All @@ -26,6 +27,9 @@ local function applyElementCustomModel(element)
setVehicleHandling(element, k, v)
end
end
if paintjob then
setVehiclePaintjob(element, paintjob)
end
end

local function loadCustomModel(customModel, elementToApply)
Expand Down Expand Up @@ -89,7 +93,7 @@ end

local function countStreamedElementsWithCustomModel(elementTypes, customModel)
local count = 0
for k, elementType in pairs(elementTypes) do
for _, elementType in pairs(elementTypes) do
for _, v in pairs(getElementsByType(elementType, root, true)) do
if getElementData(v, CUSTOM_MODEL_DATA_KEY) == customModel then
count = count + 1
Expand Down Expand Up @@ -181,16 +185,12 @@ addEventHandler("onClientElementDestroy", root, function()
freeAllocatedModelIfUnused(customModel)
end)

local function applyCustomModelsForStreamedElements()
addEventHandler("newmodels_reborn:receiveCustomModels", resourceRoot, function(customModelsFromServer)
customModels = customModelsFromServer

for _, elementType in pairs(ELEMENT_TYPES) do
for _, v in pairs(getElementsByType(elementType, root, true)) do
setElementCustomModel(v)
end
end
end

addEventHandler("newmodels_reborn:receiveCustomModels", resourceRoot, function(customModelsFromServer)
customModels = customModelsFromServer

applyCustomModelsForStreamedElements()
end, false)

0 comments on commit 325d0f5

Please sign in to comment.