Advertisement
Guest User

Chair Throwing Gun.

a guest
Aug 22nd, 2014
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.92 KB | None | 0 0
  1. if SERVER then
  2.   AddCSLuaFile (shared.lua)
  3.   SWEP.Weight = 6
  4.   SWEP.AutoSwitchTo = false
  5.   SWEP.AutoSwitchFrom = false
  6. elseif CLIENT then
  7.   SWEP.PrintName = "Chair throwing gun"
  8.   SWEP.slot = 4
  9.   SWEP.SlotPos = 1
  10.   SWEP.DrawAmmo = false
  11.   SWEP.DrawCrosshair = false
  12.   language.Add("Undone_Thrown_SWEP_Entity","Undone Thrown SWEP Entinty")
  13. end
  14.  
  15. SWEP.Author = "LGS Madara Uchiha"
  16. SWEP.Contact = "noneya"
  17. SWEP.Purpose = "Throws chairs what else did you expect?"
  18. SWEP.Instructions = "Do you really need to know? Just shoot"
  19. SWEP.Category = "Category"
  20. SWEP.ViewModel = "models/weapons/v_RPG.mdl"
  21. SWEP.WorldModel = "models/weapons/w_rocket_launcher.mdl"
  22. SWEP.Primary.ClipSize = -1
  23. SWEP.Primary.DefaultClip = -1
  24. SWEP.Primary.Automatic = true
  25. SWEP.Primary.Ammo = "none"
  26. SWEP.Secondary.ClipSize = -1
  27. SWEP.Secondary.DefaultClip = -1
  28. SWEP.Secondary.Automatic = true
  29. SWEP.Secondary.Ammo = "none"
  30.  
  31. local ShootSound = Sound("Metal.SawbladeStick")
  32.  
  33. function SWEP:Reload()
  34. end
  35.  
  36. function SWEP:Think()
  37. end
  38.  
  39. function SWEP:throw_attack (model_file)
  40.   local tr = self.owner:GetEyeTrace()
  41.   self:EmitSound (ShootSound)
  42.   self.BaseClass.ShootEffects(self)
  43.   if (!SERVER) then return end
  44.   local ent = ents.Create("prop_physics")
  45.   ent:SetModel(model_file)
  46.   ent:SetPos(self.Owner:EyePos() + (self.Owner:GetAimVector() * 16))
  47.   ent:SetAngles(self.Owner:EyeAngles())
  48.   ent:Spawn()
  49.   local phys = ent:GetPhysicsObject ()
  50.   if !(phys && IsValid(phys)) then ent:Remove() return end
  51.   phys:ApplyForceCenter(self.Owner:GetAimVector():GetNormalized() * math.pow(tr.HitPos:length(), 3))
  52.   cleanup.Add(self.Owner, "props", ent)
  53.   undo.Create ("Thrown_SWEP_Entity")
  54.     undo.AddEntity (ent)
  55.     undo.SetPlayer (self.Owner)
  56.   undo.Finish()
  57.  end
  58.  
  59. function SWEP:PrimaryAttack()
  60.   self:throw_attack(models/props/cs_office/Chair_office.mdl")
  61. end
  62.  
  63. function SWEP:SecondaryAttack()
  64.  self:throw_attack("models/props_c17/FurnitureChair001a.mdl")
  65. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement