Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if SERVER then // This is where the init.lua stuff goes.
- //This makes sure clients download the file
- AddCSLuaFile ("shared.lua")
- //How heavy the SWep is
- SWEP.Weight = 5
- //Allow automatic switching to/from this weapon when weapons are picked up
- SWEP.AutoSwitchTo = false
- SWEP.AutoSwitchFrom = false
- end
- SWEP.HoldType = "pistol"
- if CLIENT then
- SWEP.PrintName = "Testgun"
- SWEP.Slot = 3
- SWEP.ViewModelFlip = false
- SWEP.ViewModelFOV = 54
- SWEP.EquipMenuData = {
- type = "item_weapon",
- desc = "assbutt"
- };
- SWEP.Icon = "VGUI/ttt/icon_c4"
- end
- SWEP.Base = "weapon_tttbase"
- SWEP.Kind = WEAPON_EQUIP1
- SWEP.CanBuy = {ROLE_TRAITOR}
- SWEP.WeaponID = AMMO_POLTER
- SWEP.Primary.Recoil = 0.1
- SWEP.Primary.Delay = 12.0
- SWEP.Primary.Cone = 0.02
- SWEP.Primary.ClipSize = 3
- SWEP.Primary.DefaultClip = 3
- SWEP.Primary.ClipMax = 3
- SWEP.Primary.Ammo = "none"
- SWEP.Primary.Automatic = false
- SWEP.Secondary.Automatic = false
- SWEP.ViewModel = "models/weapons/v_pistol.mdl"
- SWEP.WorldModel = "models/weapons/w_pistol.mdl"
- util.PrecacheSound("weapons/slam/mine_mode.wav")
- SWEP.Primary.Sound = Sound( "weapons/airboat/airboat_gun_energy1.wav" )
- SWEP.NoSights = true
- function SWEP:Reload()
- return true
- end
- function SWEP:Think()
- end
- --
- -- Called when the left mouse button is pressed
- --
- function SWEP:PrimaryAttack()
- -- This weapon is 'automatic'. This function call below defines
- -- the rate of fire. Here we set it to shoot every 0.5 seconds.
- self.Weapon:SetNextPrimaryFire( CurTime() + 0.5 )
- -- Call 'ThrowChair' on self with this model
- self:ThrowChair()
- end
- --
- -- Called when the rightmouse button is pressed
- --
- function SWEP:SecondaryAttack()
- -- Note we don't call SetNextSecondaryFire here because it's not
- -- automatic and so we let them fire as fast as they can click.
- -- Call 'ThrowChair' on self with this model
- self:BombStick()
- end
- --
- -- A custom function we added. When you call this the player will fire a chair!
- --
- function SWEP:BombStick()
- if SERVER then
- local ply = self.Owner
- if not IsValid(ply) then return end
- if self.Planted then return end
- local ignore = {ply, self.Weapon}
- local spos = ply:GetShootPos()
- local epos = spos + ply:GetAimVector() * 800
- local tr = util.TraceLine({start=spos, endpos=epos, filter=ignore, mask=MASK_SOLID})
- if tr.HitWorld then
- local bomb = ents.Create("ttt_testwep")
- if IsValid(bomb) then
- bomb:PointAtEntity(ply)
- local tr_ent = util.TraceEntity({start=spos, endpos=epos, filter=ignore, mask=MASK_SOLID}, bomb)
- if tr_ent.HitWorld then
- local ang = tr_ent.HitNormal:Angle()
- ang:RotateAroundAxis(ang:Right(), -90)
- ang:RotateAroundAxis(ang:Up(), 180)
- bomb:SetPos(tr_ent.HitPos)
- bomb:SetAngles(ang)
- bomb:SetOwner(ply)
- bomb:Spawn()
- bomb.fingerprints = self.fingerprints
- local phys = bomb:GetPhysicsObject()
- if IsValid(phys) then
- phys:EnableMotion(false)
- end
- bomb.IsOnWall = true
- self.Planted = false
- end
- end
- ply:SetAnimation( PLAYER_ATTACK1 )
- end
- end
- end
- function SWEP:ThrowChair()
- if ( !self:CanPrimaryAttack() ) then return end
- self.Weapon:EmitSound(Sound("Weapon_AWP.Single"))
- self:TakePrimaryAmmo( 0 )
- self.Owner:ViewPunch( Angle( -1, 0, 0 ) )
- self.Weapon:SetNextPrimaryFire( CurTime() + 0.2 )
- local trace = self.Owner:GetEyeTrace()
- local effectdata = EffectData()
- effectdata:SetOrigin( trace.HitPos )
- effectdata:SetNormal( trace.HitNormal )
- effectdata:SetEntity( trace.Entity )
- effectdata:SetAttachment( trace.PhysicsBone )
- local effectdata = EffectData()
- effectdata:SetOrigin( trace.HitPos )
- effectdata:SetStart( self.Owner:GetShootPos() )
- effectdata:SetAttachment( 1 )
- effectdata:SetEntity( self.Weapon )
- util.Effect( "ToolTracer", effectdata )
- if (SERVER) then
- local owner=self.Owner if self.Owner.SENT then owner=self.Owner.SENT.Entity end
- local Explosion = ents.Create( "ttt_testwep" )
- Explosion:SetPos(trace.HitPos)
- Explosion:SetOwner(owner)
- Explosion:Spawn()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement