CapsAdmin

Untitled

Mar 12th, 2011
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.43 KB | None | 0 0
  1. --local me = nero.GetPlayer"salte" -- me is already localized, if not just uncomment this with your player name instead of "salte"
  2. local ENT = {}
  3.  
  4. ENT.Type = "anim"
  5. ENT.Base = "base_entity"
  6.  
  7. ENT.Model = Model("models/Effects/combineball.mdl")
  8. ENT.ClassName = "combat_jeep"
  9.  
  10. if CLIENT then
  11.  
  12.     function ENT:Draw()
  13.         self:DrawModel()
  14.     end
  15.  
  16. else
  17.     function ENT:Initialize()
  18.     local phys, attach, pos, ang, seat
  19.  
  20.        
  21.         self:SetModel( self.Model )
  22.         self:PhysicsInit( SOLID_VPHYSICS )
  23.         self:SetMoveType( MOVETYPE_VPHYSICS )
  24.         self:SetSolid( SOLID_VPHYSICS )
  25.         self:PhysWake()
  26.         self:SetColor(0,0,0,0)
  27.  
  28.  
  29.     local now = CurTime() - 120
  30.  
  31.  
  32.       pos = self:GetPos( )
  33.         ang = self:GetAngles( )
  34.        
  35.         ang:RotateAroundAxis( ang:Up( ), 180 )
  36.  
  37.         self.Veh = ents.Create( "prop_vehicle_jeep" )
  38.             self.Veh:SetKeyValue( "VehicleScript", "scripts/vehicles/jeep_test.txt" )
  39.             self.Veh:SetModel( "models/buggy.mdl" )
  40.             self.Veh:SetPos( self:GetPos() )
  41.             self.Veh:SetAngles( ang )
  42.         self.Veh:Spawn( )
  43.         self.Veh:DeleteOnRemove( self )
  44.  
  45.  
  46.     // Passenger Seats - Gunners
  47.     self.GunnerSeats = {}
  48.     self.MountedGuns = {}
  49.     local gunnerseats,gunnerangles,mgpos,mgang = {},{},{},{}
  50.  
  51. // Seat
  52. // Pos
  53.     gunnerseats[1] = Vector( 0, -70, 70 )
  54.     gunnerseats[2] = Vector( 20, -35, 20 )
  55. // Ang
  56.     gunnerangles[1] = Angle( 0, 0, 0 )
  57.     gunnerangles[2] = Angle( 0, 0, 0 )
  58. // Gunner
  59.  
  60.     // Mounted gun pos
  61.     mgpos[1] = Vector( 0, -50, 90 )
  62.     mgpos[2] = Vector( 17, 10, 46 )
  63.    
  64.     // Mounted gun angles
  65.     mgang[1] = Angle( 0, 90, 0 )
  66.     mgang[2] = Angle( 0, 90, 0 )
  67.    
  68.     local mnt, mntp = {},{}
  69.     mnt[1] = Angle( 0, 90, 180 )
  70.     mnt[2] = Angle( 0, -90, 180 )
  71.    
  72.     mntp[1] = Vector( 10, -32, 38.5 )
  73.     mntp[2] = Vector( 10, 32, 38.5 )
  74.  
  75.     for i=1,1 do
  76.  
  77.        
  78.         self.GunnerSeats[i] = ents.Create( "prop_vehicle_prisoner_pod" )
  79.         self.GunnerSeats[i]:SetPos( self.Veh:LocalToWorld( gunnerseats[i] ) )
  80.         self.GunnerSeats[i]:SetModel( "models/nova/jeep_seat.mdl" )
  81.         self.GunnerSeats[i]:SetKeyValue( "vehiclescript", "scripts/vehicles/prisoner_pod.txt" )
  82.         self.GunnerSeats[i]:SetKeyValue( "LimitView", "60" )
  83.         self.GunnerSeats[i].HandleAnimation = function( v, p ) return p:SelectWeightedSequence( ACT_GMOD_SIT_ROLLERCOASTER ) end
  84.         self.GunnerSeats[i]:SetAngles( self.Veh:GetAngles() + gunnerangles[i] )
  85.         self.GunnerSeats[i]:SetParent( self.Veh )
  86.         self.GunnerSeats[i]:Spawn()
  87.         self.GunnerSeats[i].isGunner = true
  88.  
  89.    
  90.         self.MountedGuns[i] = ents.Create( "prop_physics_override" )
  91.         self.MountedGuns[i]:SetPos( self.Veh:LocalToWorld( mgpos[i] ) )
  92.         self.MountedGuns[i]:SetAngles( self.Veh:GetAngles() + mgang[i] )
  93.         self.MountedGuns[i]:SetModel( "models/Airboatgun.mdl" )
  94.         self.MountedGuns[i]:SetParent( self.GunnerSeats[i] )
  95.         self.MountedGuns[i]:SetSolid( SOLID_NONE )
  96.         self.MountedGuns[i].LastAttack = now
  97.         self.MountedGuns[i]:Spawn()
  98.         self.GunnerSeats[i].MountedWeapon = self.MountedGuns[i]
  99.  
  100.  
  101.     end
  102.  
  103.     for i=2,2 do
  104.    
  105.         self.MountedGuns[i] = ents.Create( "prop_physics_override" )
  106.         self.MountedGuns[i]:SetPos( self.Veh:LocalToWorld( mgpos[i] ) )
  107.         self.MountedGuns[i]:SetAngles( self.Veh:GetAngles() + mgang[i] )
  108.         self.MountedGuns[i]:SetModel( "models/weapons/w_mach_m249para.mdl" )
  109.         self.MountedGuns[i]:SetParent( self.Veh )
  110.         self.MountedGuns[i]:SetSolid( SOLID_NONE )
  111.         self.MountedGuns[i].LastAttack = now
  112.         self.MountedGuns[i]:Spawn()
  113.        
  114.         self.GunnerSeats[i] = ents.Create( "prop_vehicle_prisoner_pod" )
  115.         self.GunnerSeats[i]:SetPos( self.Veh:LocalToWorld( gunnerseats[i] ) )
  116.         self.GunnerSeats[i]:SetModel( "models/nova/jeep_seat.mdl" )
  117.         self.GunnerSeats[i]:SetKeyValue( "vehiclescript", "scripts/vehicles/prisoner_pod.txt" )
  118.         self.GunnerSeats[i]:SetKeyValue( "LimitView", "60" )
  119.         self.GunnerSeats[i].HandleAnimation = function( v, p ) return p:SelectWeightedSequence( ACT_GMOD_SIT_ROLLERCOASTER ) end
  120.         self.GunnerSeats[i]:SetAngles( self.Veh:GetAngles() + gunnerangles[i] )
  121.         self.GunnerSeats[i]:SetParent( self.Veh )
  122.         self.GunnerSeats[i].MountedWeapon = self.MountedGuns[i]
  123.         self.GunnerSeats[i]:Spawn()
  124.         self.GunnerSeats[i].isGunner= true
  125.  
  126.     end
  127.  
  128.  
  129.  
  130.  
  131.     end
  132.  
  133.    
  134.    
  135. function ENT:Think( )
  136. timer.Create("Fuckyou"..self.Entity:EntIndex(), 0.01, 50, function()
  137. if not self:IsValid() then return end
  138.     local seat
  139.     local gunner
  140.     local wep
  141.     // Gunners
  142.     for i=1,1 do
  143.    
  144.         seat = self.GunnerSeats[i]
  145.         gunner = seat:GetDriver()
  146.         wep = seat.MountedWeapon
  147.        
  148.         if( ValidEntity( seat ) && ValidEntity( gunner ) && ValidEntity( wep ) ) then
  149.        
  150.             local ang = gunner:EyeAngles()
  151.            
  152.             if ( gunner:KeyDown( IN_ATTACK ) && wep.LastAttack + .06 <= CurTime() ) then
  153.                
  154.                 ang = ang + Angle( math.Rand(-.8,.8), math.Rand(-.8,.8), 0 )
  155.                
  156.                 local bullet = {}
  157.                 bullet.Num      = 1
  158.                 bullet.Src      = wep:GetPos() + wep:GetForward() * 55
  159.                 bullet.Dir      = wep:GetAngles():Forward()                 // Dir of bullet
  160.                 bullet.Spread   = Vector( .03, .03, .03 )               // Aim Cone
  161.                 bullet.Tracer   = 1                                         // Show a tracer on every x bullets  
  162.                 bullet.Force    = 0                                     // Amount of force to give to phys objects
  163.                 bullet.Damage   = 0
  164.                 bullet.AmmoType = "Ar2"
  165.                 bullet.TracerName = "AirboatGunHeavyTracer"
  166.                 bullet.Callback = function ( a, b, c )
  167.                                        
  168.                                         util.BlastDamage( gunner, gunner, b.HitPos, 40, 25 )
  169.                                        
  170.                                         return { damage = true, effects = DoDefaultEffect }
  171.                                        
  172.                                     end
  173.                                    
  174.                 wep:FireBullets( bullet )
  175.                 wep:EmitSound( "npc/turret_floor/shoot"..math.random(2,3)..".wav", 400, 60 )   
  176.  
  177.                 local effectdata = EffectData()
  178.                     effectdata:SetStart( wep:GetPos() )
  179.                     effectdata:SetOrigin( wep:GetPos() )
  180.                 util.Effect( "RifleShellEject", effectdata )  
  181.  
  182.                 local e = EffectData()
  183.                     e:SetStart( wep:GetPos()+wep:GetForward() * 62 )
  184.                     e:SetOrigin( wep:GetPos()+wep:GetForward() * 62 )
  185.                     e:SetEntity( wep )
  186.                     e:SetAttachment(1)
  187.                 util.Effect( "ChopperMuzzleFlash", e )
  188.  
  189.                 wep.LastAttack = CurTime() + 0.05
  190.        
  191.             end
  192.  
  193.             if gunner:KeyDown( IN_MOVELEFT ) then
  194.             ang = seat:GetAngles():Right() * 2
  195.             seatang = seat:GetAngles()
  196.             seatang:RotateAroundAxis(seatang:Up(),ang.yaw)
  197.             seat:SetAngles(seatang)
  198.             end
  199.             if gunner:KeyDown( IN_MOVERIGHT ) then
  200.             ang = seat:GetAngles():Right() * -2
  201.             seatang = seat:GetAngles()
  202.             seatang:RotateAroundAxis(seatang:Up(),ang.yaw)
  203.             seat:SetAngles(seatang)
  204.             end
  205.  
  206.            
  207.             wep:SetAngles( ang )
  208.         end
  209.        
  210.     end
  211.     //
  212.     for i=2,2 do
  213.    
  214.         seat = self.GunnerSeats[i]
  215.         gunner = seat:GetDriver()
  216.         wep = seat.MountedWeapon
  217.        
  218.         if( ValidEntity( seat ) && ValidEntity( gunner ) && ValidEntity( wep ) ) then
  219.        
  220.             local ang = gunner:EyeAngles()
  221.            
  222.             if ( gunner:KeyDown( IN_ATTACK ) && wep.LastAttack + .06 <= CurTime() ) then
  223.                
  224.                 ang = ang + Angle( math.Rand(-.8,.8), math.Rand(-.8,.8), 0 )
  225.                
  226.                 local bullet = {}
  227.                 bullet.Num      = 1
  228.                 bullet.Src      = wep:GetPos() + wep:GetForward() * 55
  229.                 bullet.Dir      = wep:GetAngles():Forward()                 // Dir of bullet
  230.                 bullet.Spread   = Vector( .04, .04, .04 )               // Aim Cone
  231.                 bullet.Tracer   = 1                                         // Show a tracer on every x bullets  
  232.                 bullet.Force    = 0                                     // Amount of force to give to phys objects
  233.                 bullet.Damage   = 5
  234.                 bullet.AmmoType = "Ar2"
  235.                 bullet.TracerName = "Tracer"                           
  236.                 wep:FireBullets( bullet )
  237.                 wep:EmitSound( "Weapon_M249.Single", 80, 60 )  
  238.  
  239.                 local effectdata = EffectData()
  240.                     effectdata:SetStart( wep:GetPos() + Vector(0,-10,6) )
  241.                     effectdata:SetOrigin( wep:GetPos() + Vector(0,-10,6)  )
  242.                     effectdata:SetAngle( wep:GetAngles() + Angle(0,90,0))
  243.                 util.Effect( "RifleShellEject", effectdata )  
  244.                 local Attachment = wep:GetAttachment( 1 )
  245.  
  246.                 local e = EffectData()
  247.                     e:SetOrigin( Attachment.Pos )
  248.                     e:SetAngle(wep:GetAngles())
  249.                     e:SetScale( 2 )
  250.                 util.Effect( "MuzzleEffect", e )
  251.  
  252.                 wep.LastAttack = CurTime()
  253.        
  254.             end
  255.  
  256.            
  257.             wep:SetAngles( ang )
  258.         end
  259.        
  260.     end
  261. end)
  262. end
  263.    
  264.    
  265. end
  266.  
  267. scripted_ents.Register(ENT, ENT.ClassName, true)
  268.  
  269. for key, entity in pairs(ents.FindByClass(ENT.ClassName)) do
  270.     table.Merge(entity:GetTable(), ENT)
  271.     entity:Initialize()
  272. end
  273.  
  274. if SERVER then
  275.     if #ents.FindByClass(ENT.ClassName) > 0 then return end
  276.  
  277.     local trace = me:GetEyeTrace()
  278.     local entity = ents.Create(ENT.ClassName)
  279.     entity:Spawn()
  280.     entity:SetPos(trace.HitPos + Vector(0,0,entity:BoundingRadius()))
  281.     entity:DropToFloor()
  282.    
  283.     undo.Create(class)
  284.         undo.SetPlayer(me)
  285.         undo.AddEntity(entity)
  286.     undo.Finish()
  287.  
  288.  
  289. end
Advertisement
Add Comment
Please, Sign In to add comment