Skip to content

Commit

Permalink
Vehicle handling fixed by MTA r22204, updated logic and min version
Browse files Browse the repository at this point in the history
thank botder for having merged multitheftauto/mtasa-blue#1935
  • Loading branch information
Fernando-A-Rocha committed Sep 17, 2023
1 parent f428193 commit 46b588b
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 24 deletions.
10 changes: 0 additions & 10 deletions newmodels/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -446,19 +446,9 @@ function setElementCustomModel(element, elementType, id)
if DATANAME_VEH_HANDLING then
local handling = getElementData(element, DATANAME_VEH_HANDLING)
if handling then
--[[
-- Sadly this doesn't work yet because MTA doesn't let you setVehicleHandling clientside on server-created vehicles
-- I hope this changes in the future (the following PR makes it possible)
-- https://github.com/multitheftauto/mtasa-blue/pull/1935
for property, value in pairs(handling) do
setVehicleHandling(element, property, value)
end
-- Temp solution below (sets the handling serverside)
--]]
triggerServerEvent(resName..":forceSetVehicleHandling", resourceRoot, element, handling)
end
end
if DATANAME_VEH_UPGRADES then
Expand Down
2 changes: 1 addition & 1 deletion newmodels/meta.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<!-- IMPORTANT TO HAVE THE VERSION
SPECIFIED SO THAT ADDED MODELS WORK AS EXPECTED
https://nightly.mtasa.com -->
<min_mta_version client="1.6.0-9.22184.0" server="1.6.0-9.22184.0"></min_mta_version>
<min_mta_version client="1.6.0-9.22204.0" server="1.6.0-9.22204.0"></min_mta_version>

<!-- Ped Mods -->
<file src="models/peds/20001.dff"/>
Expand Down
13 changes: 0 additions & 13 deletions newmodels/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

-- Internal events:
addEvent(resName..":onDownloadFailed", true)
addEvent(resName..":forceSetVehicleHandling", true)

local SERVER_READY = false
local startTickCount = nil
Expand Down Expand Up @@ -48,18 +47,6 @@ if DATANAME_VEH_HANDLING then
addDebugHook( "postFunction", onSetVehicleHandling, { "setVehicleHandling" })
end

-- Temp solution (see where it's triggered from client.lua):
-- It's not ideal because with a lot of players requesting handling this can cause server lag
function forceSetVehicleHandling(element, handling)
if not (isElement(element)) then return end
if type(handling) ~= "table" then return end
for property, value in pairs(handling) do
setVehicleHandling(element, property, value)
end
-- iprint("Force set vehicle handling", element)
end
addEventHandler(resName..":forceSetVehicleHandling", resourceRoot, forceSetVehicleHandling, false)

--[[
Goal: solve the issue of upgrades resetting every time the vehicle's model is changed serverside/clientside
]]
Expand Down

0 comments on commit 46b588b

Please sign in to comment.