Guest

Azrael

By: a guest on Mar 12th, 2009  |  syntax: Lua  |  size: 1.56 KB  |  hits: 48  |  expires: Never
download  |  raw  |  embed  |  report abuse
Copied
  1. registerCallback( 'destruct', function( context )
  2.         if context.entity.seat and context.entity.seat:IsValid() then context.entity.seat:Remove() end
  3.         if context.entity.headcrab and context.entity.headcrab:IsValid() then context.entity.headcrab:Remove() end
  4. end )
  5.  
  6. local function spawnSeat( chip, support )
  7.         if chip.seat and chip.seat:IsValid() then return end
  8.         local seat = ents.Create( 'prop_vehicle_prisoner_pod' )
  9.         seat:SetModel( 'models/Nova/airboat_seat.mdl' )
  10.         seat:SetPos( chip:GetPos() + chip:GetUp() )
  11.         seat:SetAngles( chip:GetAngles() )
  12.         seat:Spawn( )
  13.         constraint.Weld( chip, seat )
  14.         if support and support:IsValid() then
  15.                 constraint.Weld( support, seat )
  16.         end
  17.         chip.seat = seat
  18. end
  19.  
  20. registerFunction( 'getSeat', '', 'e', function( self, args )
  21.         if self.entity.seat and self.entity.seat:IsValid() then return self.entity.seat end return nil
  22. end )
  23.  
  24. registerFunction( 'spawnSeat', '', 'e', function( self, args )
  25.         spawnSeat( self.entity )
  26. end )
  27.  
  28. registerFunction( 'spawnSeat', 'e', 'e', function( self, args )
  29.         local support = args[2][1]( self, args[2] )
  30.         spawnSeat( self.entity, support )
  31. end )
  32.  
  33. registerFunction( 'despawnSeat', '', '', function( self, args )
  34.         if self.entity.seat and self.entity.seat:IsValid() then self.entity.seat:Remove() end
  35. end )
  36.  
  37. registerFunction( 'ejectSeat', '', '', function( self, args )
  38.         if !(self.entity.seat and self.entity.seat:IsValid()) then return end
  39.         constraint.RemoveConstraints( self.entity.seat, 'Weld' )
  40.         local phys = self.entity.seat:GetPhysicsObject()
  41.         phys:SetVelocity( self.entity:GetUp() * 100000 )
  42. end )