Skip to content

Commit 4928382

Browse files
committed
Only perform on successful attach/detach
1 parent 517e937 commit 4928382

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

[gameplay]/glue/logic/SVehicleAttach.lua

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,8 @@ function onServerVehicleAttachElement(attachElement, attachToElement, attachData
125125

126126
if (attachedElement) then
127127
adjustPlayerWeaponSlot(client, attachElement, playerWeaponSlot)
128+
performAttachDetachTasksForPlayer(attachElement, attachToElement)
128129
end
129-
130-
performAttachDetachTasksForPlayer(attachElement, attachToElement)
131130
end
132131
addEvent("onServerVehicleAttachElement", true)
133132
addEventHandler("onServerVehicleAttachElement", root, onServerVehicleAttachElement)
@@ -139,8 +138,11 @@ function onServerVehicleDetachElement(detachElement)
139138
return false
140139
end
141140

142-
detachElements(detachElement, detachFromElement)
143-
performAttachDetachTasksForPlayer(detachElement, false)
141+
local detachedElement = detachElements(detachElement, detachFromElement)
142+
143+
if (detachedElement) then
144+
performAttachDetachTasksForPlayer(detachElement, false)
145+
end
144146
end
145147
addEvent("onServerVehicleDetachElement", true)
146148
addEventHandler("onServerVehicleDetachElement", root, onServerVehicleDetachElement)

0 commit comments

Comments
 (0)