Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- AddCSLuaFile()
- if CLIENT then
- surface.CreateFont("CSSelectIcons", { font="csd", weight="500", size=ScreenScale(60),antialiasing=true,additive=true })
- end
- SWEP.Base = "weapon_base"
- SWEP.PrintName = "Flex's Weapon Base"
- SWEP.Author = "Flex"
- SWEP.Category = "FWP"
- SWEP.Slot = 1
- SWEP.SlotPos = 1
- SWEP.HoldType = "smg"
- SWEP.Spawnable = false
- SWEP.AdminOnly = false
- SWEP.ViewModel = "models/weapons/c_smg1.mdl"
- SWEP.WorldModel = "models/weapons/w_smg1.mdl"
- SWEP.UseHands = true
- SWEP.Primary.Sound = Sound("Weapon_SMG1.Single")
- SWEP.Primary.Delay = 0.1
- SWEP.Primary.Damage = 10
- SWEP.Primary.Spread = 0
- SWEP.Primary.Recoil = 0.5
- SWEP.Primary.Bullets = 1
- SWEP.Primary.ClipSize = 6
- SWEP.Primary.DefaultClip = 36
- SWEP.Primary.Automatic = true
- SWEP.Primary.Ammo = "smg1"
- SWEP.Secondary.ClipSize = -1
- SWEP.Secondary.DefaultClip = -1
- SWEP.Secondary.Automatic = false
- SWEP.Secondary.Ammo = "none"
- SWEP.SelectionFont = "CreditsLogo"
- SWEP.SelectionLetter = "f"
- function SWEP:DrawWeaponSelection(x,y,w,h,a)
- // Borders
- y = y + 10
- x = x + 10
- w = w - 20
- if self.SelectionFont == "CSSelectIcons" then y = y + 30 end
- draw.DrawText(self.SelectionLetter,self.SelectionFont,x+w/2,y,Color(255,220,0),TEXT_ALIGN_CENTER)
- // Draw weapon info box
- self:PrintWeaponInfo(x + w + 20, y + h * 0.95, a)
- end
- function SWEP:PrintWeaponInfo(x, y, alpha)
- if (self.DrawWeaponInfoBox == false) then return end
- if (self.InfoMarkup == nil) then
- local str
- local title_color = "<color=128,220,0,255>"
- local text_color = "<color=255,255,255,255>"
- str = "<font=HudSelectionText>"
- if (self.Author ~= "") then str = str .. title_color .. "Author:</color>\t" .. text_color .. self.Author .. "</color>\n" end
- if (self.Contact ~= "") then str = str .. title_color .. "Contact:</color>\t" .. text_color .. self.Contact .. "</color>\n\n" end
- if (self.Purpose ~= "") then str = str .. title_color .. "Purpose:</color>\n" .. text_color .. self.Purpose .. "</color>\n\n" end
- if (self.Instructions~= "") then str = str .. title_color .. "Instructions:</color>\n" .. text_color .. self.Instructions .. "</color>\n" end
- str = str .. "</font>"
- self.InfoMarkup = markup.Parse(str, 250)
- end
- alpha = 180
- surface.SetDrawColor(0, 0, 0, alpha)
- surface.SetTexture(self.SpeechBubbleLid)
- surface.DrawTexturedRect(x, y - 69.5, 128, 64)
- draw.RoundedBox(8, x - 5, y - 6, 260, self.InfoMarkup:GetHeight() + 18, Color(0, 0, 0, alpha))
- self.InfoMarkup:Draw(x + 5, y + 5, nil, nil, alpha)
- end
- function SWEP:Initialize()
- self:SetHoldType(self.HoldType)
- end
- function SWEP:ShootBullet(damage,recoil,num_bullets,aimcone)
- local bullet = {}
- bullet.Num = self.Primary.Bullets
- bullet.Src = self.Owner:GetShootPos()
- bullet.Dir = self.Owner:GetAimVector()
- bullet.Spread = Vector( self.Primary.Spread, self.Primary.Spread, 0 )
- bullet.Tracer = 5
- bullet.Force = 1
- bullet.Damage = self.Primary.Damage
- bullet.AmmoType = self.Primary.Ammo
- self.Owner:FireBullets(bullet)
- self:ShootEffects()
- if (not self.Owner:IsNPC()) and ((game.SinglePlayer() and SERVER) or (not game.SinglePlayer() and CLIENT)) then
- local eyeangle = self.Owner:EyeAngles()
- eyeangle.pitch = eyeangle.pitch - self.Primary.Recoil
- self.Owner:SetEyeAngles(eyeangle)
- end
- end
- function SWEP:PrimaryAttack()
- if self:Clip1() <= 0 then
- self:Reload()
- else
- self:SetNextPrimaryFire(CurTime()+self.Primary.Delay)
- self:SendWeaponAnim(ACT_VM_PRIMARYATTACK)
- self:EmitSound(self.Primary.Sound)
- self:TakePrimaryAmmo(1)
- self:ShootBullet()
- end
- end
- function SWEP:Reload()
- self:DefaultReload(ACT_VM_RELOAD)
- if (self:Clip1() < self.Primary.ClipSize) and (self.Owner:GetAmmoCount(self.Primary.Ammo) > 0) then
- self:SendWeaponAnim(ACT_VM_RELOAD)
- self:EmitSound(Sound("Weapon_SMG1.Reload"))
- self:SetIronsights(false)
- end
- end
- local IRONSIGHT_TIME = 0.25
- function SWEP:GetViewModelPosition( pos, ang )
- if ( !self.IronSightsPos ) then return pos, ang end
- local bIron = self:GetNWBool( "Ironsights" )
- if ( bIron != self.bLastIron ) then
- self.bLastIron = bIron
- self.fIronTime = CurTime()
- if ( bIron ) then
- self.SwayScale = 0.3
- self.BobScale = 0.1
- else
- self.SwayScale = 1.0
- self.BobScale = 1.0
- end
- end
- local fIronTime = self.fIronTime or 0
- if ( !bIron && fIronTime < CurTime() - IRONSIGHT_TIME ) then
- return pos, ang
- end
- local Mul = 1.0
- if ( fIronTime > CurTime() - IRONSIGHT_TIME ) then
- Mul = math.Clamp( (CurTime() - fIronTime) / IRONSIGHT_TIME, 0, 1 )
- if (!bIron) then Mul = 1 - Mul end
- end
- local Offset = self.IronSightsPos
- if ( self.IronSightsAng ) then
- ang = ang * 1
- ang:RotateAroundAxis( ang:Right(), self.IronSightsAng.x * Mul )
- ang:RotateAroundAxis( ang:Up(), self.IronSightsAng.y * Mul )
- ang:RotateAroundAxis( ang:Forward(), self.IronSightsAng.z * Mul )
- end
- local Right = ang:Right()
- local Up = ang:Up()
- local Forward = ang:Forward()
- pos = pos + Offset.x * Right * Mul
- pos = pos + Offset.y * Forward * Mul
- pos = pos + Offset.z * Up * Mul
- return pos, ang
- end
- function SWEP:SetIronsights( b )
- self:SetNWBool("Ironsights",b)
- end
- function SWEP:SecondaryAttack()
- if !self.IronSightsPos then return end
- if self:GetNextSecondaryFire() > CurTime() then return end
- bIronsights = !self:GetNWBool("Ironsights",false)
- self:EmitSound("weapons/draw_default.wav")
- self:SetIronsights(bIronsights)
- if self:GetNWBool("Ironsights") == true then
- self.Owner:SetFOV(65,0.2)
- else
- self.Owner:SetFOV(0,0.2)
- end
- self:SetNextSecondaryFire(CurTime()+0.3)
- end
- function SWEP:OnRestore()
- self:SetNextSecondaryFire(0)
- self:SetIronsights(false)
- end
Advertisement
Add Comment
Please, Sign In to add comment