Angel
she/her/they nonbinary transfem
- Joined
- Apr 26, 2016
- Messages
- 9,940
- Nebulae
- 8,986
Code:
SWEP.PrintName = "Chair Thrower"
SWEP.Author = "Angel"
SWEP.Instructions = "Left mouse to fire a chair. \n Right mouse to fire chair. \n Reload to fire Melons"
SWEP.Spawnable = true
SWEP.AdminOnly = true
SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = -1
SWEP.Primary.Automatic = true
SWEP.Primary.Ammo = "none"
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = "none"
SWEP.Weight = 5
SWEP.AutoSwitchTo = false
SWEP.AutoSwitchFrom = false
SWEP.Slot = 1
SWEP.SlotPos = 2
SWEP.DrawAmmo = false
SWEP.DrawCrosshair = true
SWEP.ViewModel = "models/weapons/v_pistol.mdl"
SWEP.WorldModel = "models/weapons/w_pistol.mdl"
local ShootSound1 = Sound("Metal.SawbladeStick")
local ShootSound2 = Sound("garrysmod/balloon_pop_cute.wav")
function SWEP:PrimaryAttack()
self:EmitSound( ShootSound1 )
self.Weapon:SetNextPrimaryFire( 0.5 )
self:ThrowChair( "models/props/cs_office/Chair_office.mdl" )
end
function SWEP:SecondaryAttack()
self:EmitSound( ShootSound2 )
self:ThrowChair( "models/props_c17/FurnitureChair001a.mdl" )
end
function SWEP:Reload()
self:ThrowMelon( "models/props_junk/watermelon01.mdl" )
end
function SWEP:ThrowMelon(model_file)
if ( CLIENT ) then return end
local ent = ents.Create( "prop_physics" )
if ( !IsValid( ent ) ) then return end
ent:SetModel( model_file )
ent:SetPos(self.Owner:EyePos() + (self.Owner:GetAimVector() * 16) )
ent:SetAngles( self.Owner:EyeAngles() )
ent:Spawn()
local phys = ent:GetPhysicsObject()
if ( !IsValid(phys)) then ent:Remove() return end
local velocity = self.Owner:GetAimVector()
velocity = velocity * 100
velocity = velocity + ( VectorRand() * 10)
phys:ApplyForceCenter( velocity )
cleanup.Add(self.Owner, "props", ent)
undo.Create("Thrown_Melon")
undo.AddEntity( ent )
undo.SetPlayer( self.Owner )
undo.Finish()
end
function SWEP:ThrowChair(model_file)
if ( CLIENT ) then return end
local ent = ents.Create( "prop_physics" )
if ( !IsValid( ent ) ) then return end
ent:SetModel( model_file )
ent:SetPos(self.Owner:EyePos() + (self.Owner:GetAimVector() * 16) )
ent:SetAngles( self.Owner:EyeAngles() )
ent:Spawn()
local phys = ent:GetPhysicsObject()
if ( !IsValid(phys)) then ent:Remove() return end
local velocity = self.Owner:GetAimVector()
velocity = velocity * 100
velocity = velocity + ( VectorRand() * 10)
phys:ApplyForceCenter( velocity )
cleanup.Add(self.Owner, "props", ent)
undo.Create("Thrown_Chair")
undo.AddEntity( ent )
undo.SetPlayer( self.Owner )
undo.Finish()
end
I want to make the chair throwing gun shoot three chairs a click, instead of a full auto (Mouse 1) and 1 single chair (mouse 2).
Please help.
Reactions:
List