Skip to content

Commit

Permalink
fix bad logic in onClientElementDataChange
Browse files Browse the repository at this point in the history
  • Loading branch information
Fernando-A-Rocha committed Sep 2, 2024
1 parent 6a0eb85 commit 19ff9e4
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions newmodels_reborn/scripts/core/client_logic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -236,21 +236,13 @@ addEventHandler("onClientElementDataChange", root, function(key, prevCustomModel
end
end

if not newCustomModel then
-- If resetting the custom model, free the allocated model if it's not used by any other element
local loadedModel = loadedModels[newCustomModel]
if loadedModel then
freeAllocatedModel(newCustomModel, loadedModel)
end
else
if newCustomModel then
setElementCustomModel(source)
elseif prevLoadedModelBaseModel then
-- Force-set the base model of the previous custom model if resetting the custom model
setElementModelMTA(source, prevLoadedModelBaseModel)
end
if prevCustomModel then
-- Force-set the base model of the previous custom model if resetting the custom model
if (not newCustomModel) and prevLoadedModelBaseModel then
setElementModelMTA(source, prevLoadedModelBaseModel)
end

-- Free the previous custom model if it's not used by any other element
freeAllocatedModelIfUnused(prevCustomModel)
end
Expand Down

0 comments on commit 19ff9e4

Please sign in to comment.