Advertisement
Guest User

1

a guest
May 22nd, 2015
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.03 KB | None | 0 0
  1. if (SERVER) then
  2.  
  3.     AddCSLuaFile ("shared.lua")
  4.     SWEP.Weight             = 5
  5.     SWEP.AutoSwitchTo       = false
  6.     SWEP.AutoSwitchFrom         = false
  7. end
  8.  
  9. if (CLIENT) then
  10.  
  11.     SWEP.PrintName          = "Коктель молотова"
  12.     SWEP.Slot               = 3
  13.     SWEP.SlotPos            = 1
  14.     SWEP.DrawAmmo           = true
  15.     SWEP.DrawCrosshair      = false
  16.     SWEP.ViewModelFOV           = 52
  17.     SWEP.ViewModelFlip      = false
  18.     SWEP.CSMuzzleFlashes        = false
  19.     SWEP.Category           = "Counter-Strike"
  20.  
  21.     SWEP.IconLetter             = "Q"
  22.     killicon.AddFont("weapon_molotov", "CSKillIcons", SWEP.IconLetter, Color( 255, 80, 0, 255 ))
  23. end
  24.  
  25. SWEP.Category           = "Counter-Strike"      -- Swep Categorie (You can type what your want)
  26.  
  27. SWEP.HoldType               = "grenade"
  28.  
  29.  
  30. SWEP.Spawnable              = true
  31. SWEP.AdminSpawnable             = true
  32.  
  33. SWEP.ViewModel              = "models/weapons/cstrike/c_eq_fraggrenade.mdl"
  34. SWEP.WorldModel                 = "models/weapons/w_eq_fraggrenade.mdl"
  35. SWEP.UseHands = true
  36.  
  37. SWEP.Primary.ClipSize           = 1
  38. SWEP.Primary.DefaultClip        = 1
  39. SWEP.Primary.Automatic          = false
  40. SWEP.Primary.Ammo           = "grenade"
  41.  
  42. SWEP.Secondary.ClipSize         = -1
  43. SWEP.Secondary.DefaultClip      = -1
  44. SWEP.Secondary.Automatic        = false
  45. SWEP.Secondary.Ammo             = "none"
  46.  
  47. SWEP.Primed                 = 0
  48. SWEP.Throw                  = CurTime()
  49. SWEP.PrimaryThrow               = true
  50. SWEP.ExpFactor = 3
  51. SWEP.ExpTimer = 3
  52. SWEP.Mater = "models/props_interiors/furniture_chair01a"
  53. function SWEP:Initialize()
  54.     self:SetWeaponHoldType(self.HoldType)
  55.     self:SetMaterial("models/debug/debugwhite")
  56.     self:SetColor( Color(189, 69, 24) )
  57. end
  58.  
  59. SWEP.OriginalOwner = NULL
  60. function SWEP:Equip(newowner)
  61.     if !IsValid(self.OriginalOwner) then
  62.         self.OriginalOwner = newowner
  63.         self:SetNWEntity("OriginalOwner",newowner)
  64.     end
  65. end
  66.  
  67. function SWEP:Holster()
  68.     self.Primed = 0
  69.     self.Throw = CurTime()
  70.     return true
  71. end
  72.  
  73. function SWEP:Reload()
  74.     self.Owner:DrawViewModel(true)
  75.     self.Weapon:DefaultReload(ACT_VM_DRAW)
  76. end
  77.  
  78. function SWEP:Think()
  79.     if (self:Clip1() > 0) then
  80.         self.Owner:DrawViewModel(true)
  81.     else
  82.         self.Owner:DrawViewModel(false)
  83.     end
  84.  
  85.     if self.Primed == 1 and not self.Owner:KeyDown(IN_ATTACK) and self.PrimaryThrow then
  86.         if self.Throw < CurTime() then
  87.             self.Primed = 2
  88.             self.Throw = CurTime() + 1.5
  89.  
  90.             self.Weapon:SendWeaponAnim(ACT_VM_THROW)
  91.             self.Owner:SetAnimation(PLAYER_ATTACK1)
  92.  
  93.             timer.Simple( 0.35, function()
  94.                 if (!self or !IsValid(self)) then return end
  95.                 self:ThrowFar()
  96.             end)
  97.         end
  98.  
  99.     elseif self.Primed == 1 and not self.Owner:KeyDown(IN_ATTACK2) and not self.PrimaryThrow then
  100.         if self.Throw < CurTime() then
  101.             self.Primed = 2
  102.             self.Throw = CurTime() + 1.5
  103.  
  104.             self.Weapon:SendWeaponAnim(ACT_VM_THROW)
  105.             self.Owner:SetAnimation(PLAYER_ATTACK1)
  106.  
  107.             timer.Simple( 0.35, function()
  108.                 if (!self or !IsValid(self)) then return end
  109.                 self:ThrowShort()
  110.             end)
  111.         end
  112.     end
  113. end
  114.  
  115. function SWEP:ThrowFar()
  116.     if self.Primed != 2 or !IsValid(self.Owner) then return end
  117.     local tr = self.Owner:GetEyeTrace()
  118.     if (!SERVER) then return end
  119.     local ent = ents.Create ("ent_molotov")
  120.     if self.Owner:GetNWBool("GrenadeTrail",false) == true then
  121.         util.SpriteTrail(ent, 6, Color(self.Owner:GetNWInt("GrenadeTrailR",0),self.Owner:GetNWInt("GrenadeTrailG",0),self.Owner:GetNWInt("GrenadeTrailB",0)), false, 15, 1, 10, 0.125, 'trails/laser.vmt')
  122.     end
  123.     ent:SetAngles(self:GetAngles())
  124.     ent:SetPos(self:GetPos())
  125.     for k,v in pairs(ents.GetAll()) do
  126.         if(v:GetParent()==self)then
  127.             v:SetParent(ent)
  128.         end
  129.     end
  130.     local v = self.Owner:GetShootPos()
  131.     v = v + self.Owner:GetForward() * 2
  132.     v = v + self.Owner:GetRight() * 3
  133.     v = v + self.Owner:GetUp() * -3
  134.     ent:SetPos( v )
  135.     ent:SetAngles(Angle(math.random(1,100),math.random(1,100),math.random(1,100)))
  136.     ent.GrenadeOwner = self.Owner
  137.     ent:Spawn()
  138.     local phys = ent:GetPhysicsObject()
  139.     if !IsValid(phys) then self.Weapon:SendWeaponAnim(ACT_VM_DRAW) self.Primed = 0 return end
  140.     if self.Owner:KeyDown( IN_FORWARD ) then
  141.         self.Force = 1100
  142.     elseif self.Owner:KeyDown( IN_BACK ) then
  143.         self.Force = 300
  144.     elseif self.Owner:KeyDown( IN_MOVELEFT ) then
  145.         self.Force = 700
  146.     elseif self.Owner:KeyDown( IN_MOVERIGHT ) then
  147.         self.Force = 700
  148.     else
  149.         self.Force = 700
  150.     end
  151.     phys:ApplyForceCenter(self.Owner:GetAimVector() * self.Force * 2 + Vector(0, 0, 0))
  152.     phys:AddAngleVelocity(Vector(math.random(-500,500),math.random(-500,500),math.random(-500,500)))
  153.     self.Owner:StripWeapon(self:GetClass())
  154. end
  155.  
  156. function SWEP:ThrowShort()
  157.     if self.Primed != 2 or !IsValid(self.Owner) then return end
  158.     local tr = self.Owner:GetEyeTrace()
  159.     if (!SERVER) then return end
  160.     local ent = ents.Create ("ent_molotov")
  161.     if self.Owner:GetNWBool("GrenadeTrail",false) == true then
  162.         util.SpriteTrail(ent, 6, Color(self.Owner:GetNWInt("GrenadeTrailR",0),self.Owner:GetNWInt("GrenadeTrailG",0),self.Owner:GetNWInt("GrenadeTrailB",0)), false, 15, 1, 10, 0.125, 'trails/laser.vmt')
  163.     end
  164.     ent:SetAngles(self:GetAngles())
  165.     ent:SetPos(self:GetPos())
  166.     for k,v in pairs(ents.GetAll()) do
  167.         if(v:GetParent()==self)then
  168.             v:SetParent(ent)
  169.         end
  170.     end
  171.     local v = self.Owner:GetShootPos()
  172.     v = v + self.Owner:GetForward() * 2
  173.     v = v + self.Owner:GetRight() * 3
  174.     v = v + self.Owner:GetUp() * -3
  175.     ent:SetPos( v )
  176.     ent:SetAngles(self:GetAngles())
  177.     ent.GrenadeOwner = self.Owner
  178.     ent:Spawn()
  179.     local phys = ent:GetPhysicsObject()
  180.     if !IsValid(phys) then self.Weapon:SendWeaponAnim(ACT_VM_DRAW) self.Primed = 0 return end
  181.     if self.Owner:KeyDown( IN_FORWARD ) then
  182.         self.Force = 500
  183.     elseif self.Owner:KeyDown( IN_BACK ) then
  184.         self.Force = 300
  185.     elseif self.Owner:KeyDown( IN_MOVELEFT ) then
  186.         self.Force = 500
  187.     elseif self.Owner:KeyDown( IN_MOVERIGHT ) then
  188.         self.Force = 500
  189.     else
  190.         self.Force = 500
  191.     end
  192.     phys:ApplyForceCenter(self.Owner:GetAimVector() * self.Force * 2 + Vector(0, 0, 0))
  193.     phys:AddAngleVelocity(Vector(math.random(-500,500),math.random(-500,500),math.random(-500,500)))
  194.     self.Owner:StripWeapon(self:GetClass())
  195. end
  196.  
  197. function SWEP:PrimaryAttack()
  198.  
  199.     if self.Throw < CurTime() and self.Primed == 0 and self:CanPrimaryAttack() then
  200.         self.Weapon:SendWeaponAnim(ACT_VM_PULLPIN)
  201.         self.Primed = 1
  202.         self.Throw = CurTime() + 1
  203.         self.PrimaryThrow = true
  204.     end
  205. end
  206.  
  207. function SWEP:SecondaryAttack()
  208.  
  209.     if self.Throw < CurTime() and self.Primed == 0 and self:CanPrimaryAttack() then
  210.         self.Weapon:SendWeaponAnim(ACT_VM_PULLPIN)
  211.         self.Primed = 1
  212.         self.Throw = CurTime() + 1
  213.         self.PrimaryThrow = false
  214.     end
  215. end
  216.  
  217. function SWEP:PreDrawViewModel(vm,owner,wpn)
  218.     vm:SetSubMaterial()
  219.     if self.Mater then
  220.         vm:SetSubMaterial(self.PriType or 0,self.Mater)
  221.     end
  222. end
  223.  
  224. function SWEP:PostDrawViewModel(vm, ply, weapon)
  225.     vm:SetMaterial( "" )
  226.     vm:SetSubMaterial()
  227. end
  228.  
  229. function SWEP:Deploy()
  230.     local own = self.Owner
  231.     if IsValid(own) then
  232.         if (self:Clip1() > 0) then
  233.             self.Throw = CurTime() + 0.75
  234.             self.Weapon:SendWeaponAnim(ACT_VM_DRAW)
  235.             own:DrawViewModel(true)
  236.         else
  237.             self.Throw = CurTime() + 0.75
  238.             own:DrawViewModel(false)
  239.         end
  240.     end
  241. end
  242.  
  243. function SWEP:DrawWeaponSelection(x, y, wide, tall, alpha)
  244.  
  245.     draw.SimpleText(self.IconLetter, "CSSIcons", x + wide / 2, y + tall * 0.2, Color(255, 210, 0, 255), TEXT_ALIGN_CENTER)
  246. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement