Advertisement
fakerz

assbutt1

Jun 3rd, 2013
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.37 KB | None | 0 0
  1. if SERVER then // This is where the init.lua stuff goes.
  2.  
  3. //This makes sure clients download the file
  4. AddCSLuaFile ("shared.lua")
  5.  
  6. //How heavy the SWep is
  7. SWEP.Weight = 5
  8.  
  9. //Allow automatic switching to/from this weapon when weapons are picked up
  10. SWEP.AutoSwitchTo = false
  11. SWEP.AutoSwitchFrom = false
  12. end
  13.  
  14. SWEP.HoldType = "pistol"
  15.  
  16. if CLIENT then
  17. SWEP.PrintName = "Testgun"
  18. SWEP.Slot = 3
  19.  
  20. SWEP.ViewModelFlip = false
  21. SWEP.ViewModelFOV = 54
  22.  
  23. SWEP.EquipMenuData = {
  24. type = "item_weapon",
  25. desc = "assbutt"
  26. };
  27.  
  28. SWEP.Icon = "VGUI/ttt/icon_c4"
  29. end
  30.  
  31. SWEP.Base = "weapon_tttbase"
  32. SWEP.Kind = WEAPON_EQUIP1
  33. SWEP.CanBuy = {ROLE_TRAITOR}
  34. SWEP.WeaponID = AMMO_POLTER
  35.  
  36. SWEP.Primary.Recoil = 0.1
  37. SWEP.Primary.Delay = 12.0
  38. SWEP.Primary.Cone = 0.02
  39. SWEP.Primary.ClipSize = 3
  40. SWEP.Primary.DefaultClip = 3
  41. SWEP.Primary.ClipMax = 3
  42. SWEP.Primary.Ammo = "none"
  43. SWEP.Primary.Automatic = false
  44.  
  45. SWEP.Secondary.Automatic = false
  46.  
  47.  
  48.  
  49. SWEP.ViewModel = "models/weapons/v_pistol.mdl"
  50. SWEP.WorldModel = "models/weapons/w_pistol.mdl"
  51. util.PrecacheSound("weapons/slam/mine_mode.wav")
  52. SWEP.Primary.Sound = Sound( "weapons/airboat/airboat_gun_energy1.wav" )
  53.  
  54. SWEP.NoSights = true
  55.  
  56. function SWEP:Reload()
  57. return true
  58. end
  59.  
  60. function SWEP:Think()
  61. end
  62.  
  63.  
  64. --
  65. -- Called when the left mouse button is pressed
  66. --
  67. function SWEP:PrimaryAttack()
  68.  
  69. -- This weapon is 'automatic'. This function call below defines
  70. -- the rate of fire. Here we set it to shoot every 0.5 seconds.
  71. self.Weapon:SetNextPrimaryFire( CurTime() + 0.5 )
  72. -- Call 'ThrowChair' on self with this model
  73. self:ThrowChair()
  74.  
  75. end
  76.  
  77.  
  78. --
  79. -- Called when the rightmouse button is pressed
  80. --
  81. function SWEP:SecondaryAttack()
  82.  
  83. -- Note we don't call SetNextSecondaryFire here because it's not
  84. -- automatic and so we let them fire as fast as they can click.
  85.  
  86. -- Call 'ThrowChair' on self with this model
  87. self:BombStick()
  88.  
  89.  
  90. end
  91.  
  92. --
  93. -- A custom function we added. When you call this the player will fire a chair!
  94. --
  95.  
  96. function SWEP:BombStick()
  97. if SERVER then
  98. local ply = self.Owner
  99. if not IsValid(ply) then return end
  100.  
  101. if self.Planted then return end
  102.  
  103. local ignore = {ply, self.Weapon}
  104. local spos = ply:GetShootPos()
  105. local epos = spos + ply:GetAimVector() * 800
  106. local tr = util.TraceLine({start=spos, endpos=epos, filter=ignore, mask=MASK_SOLID})
  107.  
  108. if tr.HitWorld then
  109. local bomb = ents.Create("ttt_testwep")
  110. if IsValid(bomb) then
  111. bomb:PointAtEntity(ply)
  112.  
  113. local tr_ent = util.TraceEntity({start=spos, endpos=epos, filter=ignore, mask=MASK_SOLID}, bomb)
  114.  
  115. if tr_ent.HitWorld then
  116.  
  117. local ang = tr_ent.HitNormal:Angle()
  118. ang:RotateAroundAxis(ang:Right(), -90)
  119. ang:RotateAroundAxis(ang:Up(), 180)
  120.  
  121. bomb:SetPos(tr_ent.HitPos)
  122. bomb:SetAngles(ang)
  123. bomb:SetOwner(ply)
  124. bomb:Spawn()
  125. bomb.fingerprints = self.fingerprints
  126.  
  127. local phys = bomb:GetPhysicsObject()
  128. if IsValid(phys) then
  129. phys:EnableMotion(false)
  130. end
  131.  
  132. bomb.IsOnWall = true
  133.  
  134. self.Planted = false
  135.  
  136. end
  137. end
  138.  
  139. ply:SetAnimation( PLAYER_ATTACK1 )
  140. end
  141. end
  142. end
  143.  
  144.  
  145. function SWEP:ThrowChair()
  146.  
  147.  
  148. if ( !self:CanPrimaryAttack() ) then return end
  149.  
  150. self.Weapon:EmitSound(Sound("Weapon_AWP.Single"))
  151.  
  152.  
  153.  
  154. self:TakePrimaryAmmo( 0 )
  155.  
  156. self.Owner:ViewPunch( Angle( -1, 0, 0 ) )
  157. self.Weapon:SetNextPrimaryFire( CurTime() + 0.2 )
  158.  
  159. local trace = self.Owner:GetEyeTrace()
  160.  
  161. local effectdata = EffectData()
  162. effectdata:SetOrigin( trace.HitPos )
  163. effectdata:SetNormal( trace.HitNormal )
  164. effectdata:SetEntity( trace.Entity )
  165. effectdata:SetAttachment( trace.PhysicsBone )
  166.  
  167. local effectdata = EffectData()
  168. effectdata:SetOrigin( trace.HitPos )
  169. effectdata:SetStart( self.Owner:GetShootPos() )
  170. effectdata:SetAttachment( 1 )
  171. effectdata:SetEntity( self.Weapon )
  172. util.Effect( "ToolTracer", effectdata )
  173.  
  174. if (SERVER) then
  175.  
  176. local owner=self.Owner if self.Owner.SENT then owner=self.Owner.SENT.Entity end
  177. local Explosion = ents.Create( "ttt_testwep" )
  178. Explosion:SetPos(trace.HitPos)
  179. Explosion:SetOwner(owner)
  180. Explosion:Spawn()
  181. end
  182. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement