0 Members and 1 Guest are viewing this topic.
-- Variables that are used on both client and serverSWEP.Gun = ("m9k_m79gl") -- must be the name of your swep but NO CAPITALS!if (GetConVar(SWEP.Gun.."_allowed")) != nil then if not (GetConVar(SWEP.Gun.."_allowed"):GetBool()) then SWEP.Base = "bobs_blacklisted" SWEP.PrintName = SWEP.Gun return endendSWEP.Category = "M9K Specialties"SWEP.Author = ""SWEP.Contact = ""SWEP.Purpose = ""SWEP.Instructions = ""SWEP.MuzzleAttachment = "1" -- Should be "1" for CSS models or "muzzle" for hl2 modelsSWEP.ShellEjectAttachment = "2" -- Should be "2" for CSS models or "1" for hl2 modelsSWEP.PrintName = "M79 GL" -- Weapon name (Shown on HUD) SWEP.Slot = 4 -- Slot in the weapon selection menuSWEP.SlotPos = 29 -- Position in the slotSWEP.DrawAmmo = true -- Should draw the default HL2 ammo counterSWEP.DrawWeaponInfoBox = false -- Should draw the weapon info boxSWEP.BounceWeaponIcon = false -- Should the weapon icon bounce?SWEP.DrawCrosshair = true -- set false if you want no crosshairSWEP.Weight = 30 -- rank relative ot other weapons. bigger is betterSWEP.AutoSwitchTo = true -- Auto switch to if we pick it upSWEP.AutoSwitchFrom = true -- Auto switch from if you pick up a better weaponSWEP.HoldType = "shotgun" -- how others view you carrying the weapon-- normal melee melee2 fist knife smg ar2 pistol rpg physgun grenade shotgun crossbow slam passive -- you're mostly going to use ar2, smg, shotgun or pistol. rpg and crossbow make for good sniper riflesSWEP.ViewModelFOV = 70SWEP.ViewModelFlip = falseSWEP.ViewModel = "models/weapons/v_m79_grenadelauncher.mdl" -- Weapon view modelSWEP.WorldModel = "models/weapons/w_m79_grenadelauncher.mdl" -- Weapon world modelSWEP.ShowWorldModel = trueSWEP.Base = "bobs_shotty_base"SWEP.Spawnable = trueSWEP.AdminSpawnable = trueSWEP.FiresUnderwater = falseSWEP.Primary.Sound = Sound("40mmGrenade.Single") -- Script that calls the primary fire soundSWEP.Primary.RPM = 15 -- This is in Rounds Per MinuteSWEP.Primary.ClipSize = 1 -- Size of a clipSWEP.Primary.DefaultClip = 1 -- Bullets you start withSWEP.Primary.KickUp = 0.3 -- Maximum up recoil (rise)SWEP.Primary.KickDown = 0.3 -- Maximum down recoil (skeet)SWEP.Primary.KickHorizontal = 0.3 -- Maximum up recoil (stock)SWEP.Primary.Automatic = false -- Automatic = true; Semi Auto = falseSWEP.Primary.Ammo = "40mmGrenade" SWEP.Secondary.IronFOV = 60 -- How much you 'zoom' in. Less is more! SWEP.Primary.Round = ("m9k_milkor_nade") --NAME OF ENTITY GOES HERESWEP.data = {} --The starting firemodeSWEP.data.ironsights = 1SWEP.ShellTime = .5SWEP.Primary.NumShots = 1 -- How many bullets to shoot per trigger pullSWEP.Primary.Damage = 30 -- Base damage per bulletSWEP.Primary.Spread = .025 -- Define from-the-hip accuracy (1 is terrible, .0001 is exact)SWEP.Primary.IronAccuracy = .015 -- Ironsight accuracy, should be the same for shotguns-- Enter iron sight info and bone mod info belowSWEP.IronSightsPos = Vector(-4.633, -7.651, 2.108)SWEP.IronSightsAng = Vector(1.294, 0.15, 0)SWEP.SightsPos = Vector(-4.633, -7.651, 2.108)SWEP.SightsAng = Vector(1.294, 0.15, 0)SWEP.RunSightsPos = Vector(3.279, -5.574, 0)SWEP.RunSightsAng = Vector(-1.721, 49.917, 0)-- SWEP.WElements = { -- ["launcher"] = { type = "Model", model = "models/weapons/w_m79_grenadelauncher.mdl", bone = "ValveBiped.Bip01_R_Hand", rel = "", pos = Vector(44.681, 1.463, -11), angle = Angle(-180, -91.008, 16.164), size = Vector(1.378, 1.378, 1.378), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} }-- }function SWEP:Deploy() if not IsValid(self) then return end if not IsValid(self.Owner) then return end if not self.Owner:IsPlayer() then return end self:SetHoldType(self.HoldType) local timerName = "ShotgunReload_" .. self.Owner:UniqueID() if (timer.Exists(timerName)) then timer.Destroy(timerName) end self.Weapon:SendWeaponAnim(ACT_VM_DRAW) self.Weapon:SetNextPrimaryFire(CurTime() + .25) self.Weapon:SetNextSecondaryFire(CurTime() + .25) self.ActionDelay = (CurTime() + .25) -----------------------------------------self.Weapon.NextFireTime = (CurTime() + .25) if (SERVER) then self:SetIronsights(false) end self.NextReload = CurTime() + 1 return trueendfunction SWEP:PrimaryAttack() if self:CanPrimaryAttack() then ------------------------------------- and self.Weapon.NextFireTime <= CurTime() then if !self.Owner:KeyDown(IN_SPEED) and !self.Owner:KeyDown(IN_RELOAD) then self:FireRocket() self.Weapon:EmitSound(self.Primary.Sound) self.Weapon:TakePrimaryAmmo(1) self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK ) local fx = EffectData() self.Owner:SetAnimation( PLAYER_ATTACK1 ) self.Owner:MuzzleFlash() self.Weapon:SetNextPrimaryFire(CurTime()+1.75) ----------------------------------------------------self.Weapon.NextFireTime = (CurTime() + 2) else self:Reload() end end self:CheckWeaponsAndAmmo()endfunction SWEP:FireRocket() local aim = self.Owner:GetAimVector() local side = aim:Cross(Vector(0,0,1)) local up = side:Cross(aim) local pos = self.Owner:GetShootPos() + side * 6 + up * -5 if SERVER then local rocket = ents.Create(self.Primary.Round) if !rocket:IsValid() then return false end rocket:SetAngles(aim:Angle()+Angle(90,0,0)) rocket:SetPos(pos) rocket:SetOwner(self.Owner) rocket:Spawn() rocket:Activate() endendfunction SWEP:Reload() if not IsValid(self) then return end if not IsValid(self.Owner) then return end if not self.Owner:IsPlayer() then return end local maxcap = self.Primary.ClipSize local spaceavail = self.Weapon:Clip1() local shellz = (maxcap) - (spaceavail) + 1 if (timer.Exists("ShotgunReload")) or self.NextReload > CurTime() or maxcap == spaceavail then return end if self.Owner:IsPlayer() then self.Weapon:SetNextPrimaryFire(CurTime() + 1.75) -- wait one second before you can shoot again self.Weapon:SendWeaponAnim(ACT_SHOTGUN_RELOAD_START) -- sending start reload anim self.Owner:SetAnimation( PLAYER_RELOAD ) self.NextReload = CurTime() + 1 if (SERVER) then self.Owner:SetFOV( 0, 0.15 ) self:SetIronsights(false) end if SERVER and self.Owner:Alive() then local timerName = "ShotgunReload_" .. self.Owner:UniqueID() timer.Create(timerName, (self.ShellTime + .05), shellz, function() if not IsValid(self) then return end if IsValid(self.Owner) and IsValid(self.Weapon) then if self.Owner:Alive() then self:InsertShell() end end end) end elseif self.Owner:IsNPC() then self.Weapon:DefaultReload(ACT_VM_RELOAD) end endfunction SWEP:CheckWeaponsAndAmmo() if SERVER and self.Weapon != nil then if self.Weapon:Clip1() == 0 && self.Owner:GetAmmoCount( self.Weapon:GetPrimaryAmmoType() ) == 0 and (GetConVar("M9KWeaponStrip"):GetBool()) then timer.Simple(.5, function() if SERVER then if not IsValid(self) then return end if not IsValid(self.Owner) then return end self.Owner:StripWeapon(self.Gun) end end) else self:Reload() end endendfunction SWEP:Think() if not IsValid(self) then return end if not IsValid(self.Owner) then return end if not self.Owner:IsPlayer() then return end if self.InsertingShell == true and self.Owner:Alive() then vm = self.Owner:GetViewModel()-- its a messy way to do it, but holy shit, it works! vm:ResetSequence(vm:LookupSequence("after_reload")) -- Fuck you, garry, why the hell can't I reset a sequence in multiplayer? vm:SetPlaybackRate(.01) -- or if I can, why does facepunch have to be such a shitty community, and your wiki have to be an unreadable goddamn mess? self.InsertingShell = false -- You get paid for this, what's your excuse? end self:IronSight() endif GetConVar("M9KDefaultClip") == nil then print("M9KDefaultClip is missing! You may have hit the lua limit!")else if GetConVar("M9KDefaultClip"):GetInt() != -1 then SWEP.Primary.DefaultClip = SWEP.Primary.ClipSize * GetConVar("M9KDefaultClip"):GetInt() endendif GetConVar("M9KUniqueSlots") != nil then if not (GetConVar("M9KUniqueSlots"):GetBool()) then SWEP.SlotPos = 2 endend
I personally think that explosives in general are a bad route to go down without a stable server, and with HRPs' tenancy to crash with even the amount of props 30 people all sum up to, I highly discourage the use of this. Although, it is a wonderful idea!
I don't think it would bother performance as in my experience most BMD items are barely used especially something highly expensive like explosives however, I wouldn't want the RPG to have a cheaper counterpart.