Skip to content

Commit

Permalink
driverseat legality check
Browse files Browse the repository at this point in the history
yes
  • Loading branch information
KemGus committed Oct 2, 2023
1 parent cc64ee0 commit ba9fb14
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lua/entities/acf_engine/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,14 @@ function ENT:ACF_OnDamage( Entity, Energy, FrArea, Angle, Inflictor, _, Type ) -
return HitRes --This function needs to return HitRes
end

function ENT:IllegalCrewSeatRemove(crewEntities)
for _, crewEnt in ipairs(crewEntities) do
if not crewEnt.Legal then
self:Unlink(crewEnt)
end
end
end

function ENT:Think()

if ACF.CurTime > self.NextLegalCheck then
Expand All @@ -380,6 +388,8 @@ function ENT:Think()
self:UpdateOverlayText()
self.NextUpdate = ACF.CurTime + 1

self:IllegalCrewSeatRemove(self.CrewLink)

if not self.Legal and self.Active then
self:TriggerInput("Active",0) -- disable if not legal and active
self.LockOnActive = true
Expand Down Expand Up @@ -734,6 +744,10 @@ function ENT:Link( Target )

if Target:GetClass() == "ace_crewseat_driver" then

if not Target.Legal then
return false, "The driver seat is illegal!"
end

if self.HasDriver == 1 then
return false, "The engine already has a driver!"
end
Expand Down

0 comments on commit ba9fb14

Please sign in to comment.