1
0
mirror of https://github.com/metrostroi-repo/MetrostroiAddon.git synced 2026-05-02 00:42:29 +00:00

Удаление удочки из тележки сразу по её отключению

This commit is contained in:
kosmik641
2024-11-15 17:00:20 +03:00
parent ff80af115a
commit a7976c9fc9
2 changed files with 4 additions and 6 deletions

View File

@@ -22,13 +22,15 @@ local function removeWeldBetweenEnts(ent1,ent2)
end end
end end
function ENT:Use(ply) function ENT:Use(ply)
if self.Coupled then if IsValid(self.Coupled) then
sound.Play("buttons/lever8.wav",self:GetPos()) sound.Play("buttons/lever8.wav",self:GetPos())
removeWeldBetweenEnts(self,self.Coupled) removeWeldBetweenEnts(self,self.Coupled)
removeWeldBetweenEnts(self.Coupled,self) removeWeldBetweenEnts(self.Coupled,self)
self.Coupled.Connectors[self.ConnectorID] = nil
self.Timer = CurTime()+2 self.Timer = CurTime()+2
end end
self.ConnectorID = nil
self.Coupled = nil self.Coupled = nil
if ( self:IsPlayerHolding() ) then return end if ( self:IsPlayerHolding() ) then return end
if ply.PickupObject then ply:PickupObject( self ) end if ply.PickupObject then ply:PickupObject( self ) end

View File

@@ -392,17 +392,13 @@ function ENT:CheckContact(pos,dir,id,cpos)
traceEnt:SetPos(self:LocalToWorld(cpos)) traceEnt:SetPos(self:LocalToWorld(cpos))
traceEnt:SetAngles(self:GetAngles()) traceEnt:SetAngles(self:GetAngles())
traceEnt.Coupled = self traceEnt.Coupled = self
traceEnt.ConnectorID = id
sound.Play("udochka_connect.wav",traceEnt:GetPos()) sound.Play("udochka_connect.wav",traceEnt:GetPos())
self.Connectors[id] = traceEnt self.Connectors[id] = traceEnt
DropEntityIfHeld(traceEnt) DropEntityIfHeld(traceEnt)
end end
end end
return false return false
elseif self.Connectors[id] == traceEnt then
if traceEnt.Coupled == nil then
self.Connectors[id] = nil
end
return false
elseif traceEnt:GetClass() == "player" and self.Voltage > 40 then elseif traceEnt:GetClass() == "player" and self.Voltage > 40 then
local pPos = traceEnt:GetPos() local pPos = traceEnt:GetPos()
self.VoltageDropByTouch = (self.VoltageDropByTouch or 0) + 1 self.VoltageDropByTouch = (self.VoltageDropByTouch or 0) + 1