
Azrael
By: a guest on Mar 12th, 2009 | syntax:
Lua | size: 1.56 KB | hits: 48 | expires: Never
registerCallback( 'destruct', function( context )
if context.entity.seat and context.entity.seat:IsValid() then context.entity.seat:Remove() end
if context.entity.headcrab and context.entity.headcrab:IsValid() then context.entity.headcrab:Remove() end
end )
local function spawnSeat( chip, support )
if chip.seat and chip.seat:IsValid() then return end
local seat = ents.Create( 'prop_vehicle_prisoner_pod' )
seat:SetModel( 'models/Nova/airboat_seat.mdl' )
seat:SetPos( chip:GetPos() + chip:GetUp() )
seat:SetAngles( chip:GetAngles() )
seat:Spawn( )
constraint.Weld( chip, seat )
if support and support:IsValid() then
constraint.Weld( support, seat )
end
chip.seat = seat
end
registerFunction( 'getSeat', '', 'e', function( self, args )
if self.entity.seat and self.entity.seat:IsValid() then return self.entity.seat end return nil
end )
registerFunction( 'spawnSeat', '', 'e', function( self, args )
spawnSeat( self.entity )
end )
registerFunction( 'spawnSeat', 'e', 'e', function( self, args )
local support = args[2][1]( self, args[2] )
spawnSeat( self.entity, support )
end )
registerFunction( 'despawnSeat', '', '', function( self, args )
if self.entity.seat and self.entity.seat:IsValid() then self.entity.seat:Remove() end
end )
registerFunction( 'ejectSeat', '', '', function( self, args )
if !(self.entity.seat and self.entity.seat:IsValid()) then return end
constraint.RemoveConstraints( self.entity.seat, 'Weld' )
local phys = self.entity.seat:GetPhysicsObject()
phys:SetVelocity( self.entity:GetUp() * 100000 )
end )