Skip to content

Commit

Permalink
Update v1.6.0: fixed custom ID not applying + re-enabled cmd /myskin
Browse files Browse the repository at this point in the history
  • Loading branch information
Fernando-A-Rocha committed Nov 21, 2021
1 parent 7debde6 commit 38f6b25
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
24 changes: 18 additions & 6 deletions newmodels/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ local waiting_queue = {} -- [element] = { func num, args }
-- Vehicle specific
local update_handling = {} -- [element] = timer

function isClientReady() -- [Exported]
return received_modlist ~= nil
end

function getModList() -- [Exported - Client Version]
if not received_modlist then
-- outputDebugString("getModDataFromID: Client hasn't received modList yet", 1)
Expand All @@ -48,6 +52,11 @@ function getModDataFromID(id) -- [Exported - Client Version]
end
end

function wasElementCreatedClientside(element, elementType)
-- TODO
return false
end

function allocateNewMod(element, elementType, id)

if not isElementStreamedIn(element) then
Expand Down Expand Up @@ -213,8 +222,8 @@ function setElementCustomModel(element, elementType, id)
if getElementType(element)=="vehicle" then
if isTimer(update_handling[element]) then killTimer(update_handling[element]) end
update_handling[element] = setTimer(function()
if isElement(element) then
triggerLatentServerEvent("newmodels:updateVehicleHandling", resourceRoot, element)
if isElement(element) and not wasElementCreatedClientside(element) then
triggerServerEvent("newmodels:updateVehicleHandling", resourceRoot, element)
end
update_handling[element] = nil
end, 1000, 1)
Expand Down Expand Up @@ -344,7 +353,9 @@ function updateElementOnDataChange(source, theKey, oldValue, newValue)

if tonumber(oldValue) then
-- removing new model id
triggerServerEvent("newmodels:resetElementModel", resourceRoot, source, tonumber(oldValue))
if not wasElementCreatedClientside(source) then
triggerServerEvent("newmodels:resetElementModel", resourceRoot, source, tonumber(oldValue))
end
end
end

Expand Down Expand Up @@ -385,7 +396,10 @@ function updateStreamedInElement(source)
if isCustomModID(id) then

local allocated_id = allocated_ids[id]
if allocated_id then return end -- ignore if already allocated:
if allocated_id then
setElementModel(source, allocated_id)
return
end
-- the model only needs to be set once in onClientElementDataChange
-- note: when an element is streamed out the model is deallocated/freed

Expand Down Expand Up @@ -556,8 +570,6 @@ function updateStreamedElements()

freed[id] = true
freeElementCustomMod(id)
-- triggerServerEvent("newmodels:resetElementModel", resourceRoot, source, tonumber(oldValue))

else
updateStreamedInElement(el)
end
Expand Down
4 changes: 3 additions & 1 deletion newmodels/meta.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!-- DOCUMENTATION:
https://github.com/Fernando-A-Rocha/mta-add-models
-->
<info author="Fernando" name="mta-add-models" description="minimalistic library for adding new models to your server" version="1.5.1" type="script"/>
<info author="Fernando" name="mta-add-models" description="minimalistic library for adding new models to your server" version="1.6.0" type="script"/>

<!-- https://nightly.mtasa.com IMPORTANT TO HAVE THE VERSION SPECIFIED SO THAT ADDED MODELS WORK AS EXPECTED -->
<min_mta_version client="1.5.9-9.21026.0" server="1.5.9-9.21026.0"></min_mta_version>
Expand Down Expand Up @@ -49,4 +49,6 @@
<export type="server" function="addExternalMod_IDFilenames"/>
<export type="server" function="addExternalMod_CustomFilenames"/>
<export type="server" function="removeExternalMod"/>

<export type="client" function="isClientReady"/>
</meta>
2 changes: 1 addition & 1 deletion newmodels/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ function mySkinCmd(thePlayer, cmd, id)
outputChatBox("Skin ID "..id.." doesn't exist", thePlayer,255,0,0)
end
end
-- addCommandHandler("myskin", mySkinCmd, false, false)
addCommandHandler("myskin", mySkinCmd, false, false)

function pedSkinCmd(thePlayer, cmd, id)

Expand Down

0 comments on commit 38f6b25

Please sign in to comment.