-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #381 from thecraftianman/seat-legality
Add legality checks for seats
- Loading branch information
Showing
5 changed files
with
66 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
-- Optional functionality for legality checking on all vehicles | ||
|
||
hook.Add("OnEntityCreated", "ACF_SeatLegality", function(Entity) | ||
timer.Simple(0, function() | ||
if not IsValid(Entity) then return end | ||
if Entity:GetClass() ~= "prop_vehicle_prisoner_pod" then return end | ||
if Entity.fphysSeat then return end -- simfphys vehicles will make non-solid seats that should be ignored | ||
|
||
local PhysObj = Entity:GetPhysicsObject() | ||
if not IsValid(PhysObj) then return end | ||
|
||
Entity.ACF = {} | ||
Entity.ACF.PhysObj = PhysObj | ||
Entity.ACF.LegalMass = PhysObj:GetMass() | ||
Entity.ACF.Model = Entity:GetModel() | ||
Entity.ACF.LegalSeat = true | ||
Entity.WireDebugName = Entity.WireDebugName or (Entity.VehicleTable and Entity.VehicleTable.Name) or "ACF Legal Vehicle" | ||
|
||
Entity.Enable = function() | ||
Entity.ACF.LegalSeat = true | ||
end | ||
|
||
Entity.Disable = function() | ||
Entity.ACF.LegalSeat = false | ||
|
||
local Driver = Entity:GetDriver() | ||
if not IsValid(Driver) then return end | ||
Driver:ExitVehicle() | ||
end | ||
|
||
if not ACF.VehicleLegalChecks then return end | ||
|
||
ACF.CheckLegal(Entity) | ||
end) | ||
end) | ||
|
||
hook.Add("CanPlayerEnterVehicle", "ACF_SeatLegality", function(Player, Entity) | ||
if not Entity.ACF then return end | ||
|
||
if not Entity.ACF.LegalSeat then | ||
ACF.SendNotify(Player, false, "Seat is not legal and is currently disabled.") | ||
return false | ||
end | ||
end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters