Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (SERVER) then
- AddCSLuaFile ("shared.lua")
- SWEP.Weight = 5
- SWEP.AutoSwitchTo = false
- SWEP.AutoSwitchFrom = false
- end
- if (CLIENT) then
- SWEP.PrintName = "Коктель молотова"
- SWEP.Slot = 3
- SWEP.SlotPos = 1
- SWEP.DrawAmmo = true
- SWEP.DrawCrosshair = false
- SWEP.ViewModelFOV = 52
- SWEP.ViewModelFlip = false
- SWEP.CSMuzzleFlashes = false
- SWEP.Category = "Counter-Strike"
- SWEP.IconLetter = "Q"
- killicon.AddFont("weapon_molotov", "CSKillIcons", SWEP.IconLetter, Color( 255, 80, 0, 255 ))
- end
- SWEP.Category = "Counter-Strike" -- Swep Categorie (You can type what your want)
- SWEP.HoldType = "grenade"
- SWEP.Spawnable = true
- SWEP.AdminSpawnable = true
- SWEP.ViewModel = "models/weapons/cstrike/c_eq_fraggrenade.mdl"
- SWEP.WorldModel = "models/weapons/w_eq_fraggrenade.mdl"
- SWEP.UseHands = true
- SWEP.Primary.ClipSize = 1
- SWEP.Primary.DefaultClip = 1
- SWEP.Primary.Automatic = false
- SWEP.Primary.Ammo = "grenade"
- SWEP.Secondary.ClipSize = -1
- SWEP.Secondary.DefaultClip = -1
- SWEP.Secondary.Automatic = false
- SWEP.Secondary.Ammo = "none"
- SWEP.Primed = 0
- SWEP.Throw = CurTime()
- SWEP.PrimaryThrow = true
- SWEP.ExpFactor = 3
- SWEP.ExpTimer = 3
- SWEP.Mater = "models/props_interiors/furniture_chair01a"
- function SWEP:Initialize()
- self:SetWeaponHoldType(self.HoldType)
- self:SetMaterial("models/debug/debugwhite")
- self:SetColor( Color(189, 69, 24) )
- end
- SWEP.OriginalOwner = NULL
- function SWEP:Equip(newowner)
- if !IsValid(self.OriginalOwner) then
- self.OriginalOwner = newowner
- self:SetNWEntity("OriginalOwner",newowner)
- end
- end
- function SWEP:Holster()
- self.Primed = 0
- self.Throw = CurTime()
- return true
- end
- function SWEP:Reload()
- self.Owner:DrawViewModel(true)
- self.Weapon:DefaultReload(ACT_VM_DRAW)
- end
- function SWEP:Think()
- if (self:Clip1() > 0) then
- self.Owner:DrawViewModel(true)
- else
- self.Owner:DrawViewModel(false)
- end
- if self.Primed == 1 and not self.Owner:KeyDown(IN_ATTACK) and self.PrimaryThrow then
- if self.Throw < CurTime() then
- self.Primed = 2
- self.Throw = CurTime() + 1.5
- self.Weapon:SendWeaponAnim(ACT_VM_THROW)
- self.Owner:SetAnimation(PLAYER_ATTACK1)
- timer.Simple( 0.35, function()
- if (!self or !IsValid(self)) then return end
- self:ThrowFar()
- end)
- end
- elseif self.Primed == 1 and not self.Owner:KeyDown(IN_ATTACK2) and not self.PrimaryThrow then
- if self.Throw < CurTime() then
- self.Primed = 2
- self.Throw = CurTime() + 1.5
- self.Weapon:SendWeaponAnim(ACT_VM_THROW)
- self.Owner:SetAnimation(PLAYER_ATTACK1)
- timer.Simple( 0.35, function()
- if (!self or !IsValid(self)) then return end
- self:ThrowShort()
- end)
- end
- end
- end
- function SWEP:ThrowFar()
- if self.Primed != 2 or !IsValid(self.Owner) then return end
- local tr = self.Owner:GetEyeTrace()
- if (!SERVER) then return end
- local ent = ents.Create ("ent_molotov")
- if self.Owner:GetNWBool("GrenadeTrail",false) == true then
- 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')
- end
- ent:SetAngles(self:GetAngles())
- ent:SetPos(self:GetPos())
- for k,v in pairs(ents.GetAll()) do
- if(v:GetParent()==self)then
- v:SetParent(ent)
- end
- end
- local v = self.Owner:GetShootPos()
- v = v + self.Owner:GetForward() * 2
- v = v + self.Owner:GetRight() * 3
- v = v + self.Owner:GetUp() * -3
- ent:SetPos( v )
- ent:SetAngles(Angle(math.random(1,100),math.random(1,100),math.random(1,100)))
- ent.GrenadeOwner = self.Owner
- ent:Spawn()
- local phys = ent:GetPhysicsObject()
- if !IsValid(phys) then self.Weapon:SendWeaponAnim(ACT_VM_DRAW) self.Primed = 0 return end
- if self.Owner:KeyDown( IN_FORWARD ) then
- self.Force = 1100
- elseif self.Owner:KeyDown( IN_BACK ) then
- self.Force = 300
- elseif self.Owner:KeyDown( IN_MOVELEFT ) then
- self.Force = 700
- elseif self.Owner:KeyDown( IN_MOVERIGHT ) then
- self.Force = 700
- else
- self.Force = 700
- end
- phys:ApplyForceCenter(self.Owner:GetAimVector() * self.Force * 2 + Vector(0, 0, 0))
- phys:AddAngleVelocity(Vector(math.random(-500,500),math.random(-500,500),math.random(-500,500)))
- self.Owner:StripWeapon(self:GetClass())
- end
- function SWEP:ThrowShort()
- if self.Primed != 2 or !IsValid(self.Owner) then return end
- local tr = self.Owner:GetEyeTrace()
- if (!SERVER) then return end
- local ent = ents.Create ("ent_molotov")
- if self.Owner:GetNWBool("GrenadeTrail",false) == true then
- 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')
- end
- ent:SetAngles(self:GetAngles())
- ent:SetPos(self:GetPos())
- for k,v in pairs(ents.GetAll()) do
- if(v:GetParent()==self)then
- v:SetParent(ent)
- end
- end
- local v = self.Owner:GetShootPos()
- v = v + self.Owner:GetForward() * 2
- v = v + self.Owner:GetRight() * 3
- v = v + self.Owner:GetUp() * -3
- ent:SetPos( v )
- ent:SetAngles(self:GetAngles())
- ent.GrenadeOwner = self.Owner
- ent:Spawn()
- local phys = ent:GetPhysicsObject()
- if !IsValid(phys) then self.Weapon:SendWeaponAnim(ACT_VM_DRAW) self.Primed = 0 return end
- if self.Owner:KeyDown( IN_FORWARD ) then
- self.Force = 500
- elseif self.Owner:KeyDown( IN_BACK ) then
- self.Force = 300
- elseif self.Owner:KeyDown( IN_MOVELEFT ) then
- self.Force = 500
- elseif self.Owner:KeyDown( IN_MOVERIGHT ) then
- self.Force = 500
- else
- self.Force = 500
- end
- phys:ApplyForceCenter(self.Owner:GetAimVector() * self.Force * 2 + Vector(0, 0, 0))
- phys:AddAngleVelocity(Vector(math.random(-500,500),math.random(-500,500),math.random(-500,500)))
- self.Owner:StripWeapon(self:GetClass())
- end
- function SWEP:PrimaryAttack()
- if self.Throw < CurTime() and self.Primed == 0 and self:CanPrimaryAttack() then
- self.Weapon:SendWeaponAnim(ACT_VM_PULLPIN)
- self.Primed = 1
- self.Throw = CurTime() + 1
- self.PrimaryThrow = true
- end
- end
- function SWEP:SecondaryAttack()
- if self.Throw < CurTime() and self.Primed == 0 and self:CanPrimaryAttack() then
- self.Weapon:SendWeaponAnim(ACT_VM_PULLPIN)
- self.Primed = 1
- self.Throw = CurTime() + 1
- self.PrimaryThrow = false
- end
- end
- function SWEP:PreDrawViewModel(vm,owner,wpn)
- vm:SetSubMaterial()
- if self.Mater then
- vm:SetSubMaterial(self.PriType or 0,self.Mater)
- end
- end
- function SWEP:PostDrawViewModel(vm, ply, weapon)
- vm:SetMaterial( "" )
- vm:SetSubMaterial()
- end
- function SWEP:Deploy()
- local own = self.Owner
- if IsValid(own) then
- if (self:Clip1() > 0) then
- self.Throw = CurTime() + 0.75
- self.Weapon:SendWeaponAnim(ACT_VM_DRAW)
- own:DrawViewModel(true)
- else
- self.Throw = CurTime() + 0.75
- own:DrawViewModel(false)
- end
- end
- end
- function SWEP:DrawWeaponSelection(x, y, wide, tall, alpha)
- draw.SimpleText(self.IconLetter, "CSSIcons", x + wide / 2, y + tall * 0.2, Color(255, 210, 0, 255), TEXT_ALIGN_CENTER)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement