So I have been making this little SWEP that ive been wanting to see for a while, and I have it all set up, But I want it to shoot melons.. Yea its that serious... Anyways, I cant find what I need to do to change the bullet type, so ANY help is appreciated!
[lua]AddCSLuaFile()
SWEP.Base = "weapon_base"
SWEP.PrintName = "Melon Launcher"
SWEP.Slot = 1
SWEP.SlotPos = 1
SWEP.DrawAmmo = true
SWEP.DrawCrosshair = true
SWEP.ViewModel = "models/weapons/v_rpg.mdl"
SWEP.WorldModel = "models/weapons/w_rocket_launcher.mdl"
SWEP.ReloadSound = "Weapon_Shotgun.Reload"
SWEP.HoldType = "fist"
-- Other settings
SWEP.Weight = 10
SWEP.AutoSwitchTo = true
SWEP.Spawnable = true
-- Weapon info
SWEP.Author = "HackneyNoHacker"
SWEP.Contact = "marcushackney87@hotmail.com"
SWEP.Purpose = "Raging Homosexual"
SWEP.Instructions = "Go and fuck yourself."
-- Primary fire settings
SWEP.Primary.Sound = "Weapon_Mortar.Single"
SWEP.Primary.Damage = 100
SWEP.Primary.NumShots = 1
SWEP.Primary.Recoil = 3
SWEP.Primary.Cone = 2
SWEP.Primary.Delay = 0,18
SWEP.Primary.ClipSize = 30
SWEP.Primary.DefaultClip = 30
SWEP.Primary.Tracer = 1
SWEP.Primary.Force = 200
SWEP.Primary.Automatic = 10
SWEP.Primary.Ammo = "RPG_Round"
SWEP.Category = "Melon Launcher"
-- Secondary fire settings
SWEP.Secondary.Sound = "Weapon_Mortar.Single"
SWEP.Secondary.Damage = 100
SWEP.Secondary.NumShots = 5
SWEP.Secondary.Recoil = 3
SWEP.Secondary.Cone = 5
SWEP.Secondary.Delay = 0,18
SWEP.Secondary.ClipSize = 30
SWEP.Secondary.DefaultClip = 30
SWEP.Secondary.Tracer = 1
SWEP.Secondary.Force = 200
SWEP.Secondary.Automatic = true
SWEP.Secondary.Ammo = "RPG_Round"
function SWEP:Initialize()
end
function SWEP:PrimaryAttack()
if ( !self:CanPrimaryAttack() ) then return end
local bullet = {} -- Set up the shot
bullet.Num = self.Primary.NumShots
bullet.Src = self.Owner:GetShootPos()
bullet.Dir = self.Owner:GetAimVector()
bullet.Spread = Vector( self.Primary.Cone / 90, self.Primary.Cone / 90, 0 )
bullet.Tracer = self.Primary.Tracer
bullet.Force = self.Primary.Force
bullet.Damage = self.Primary.Damage
bullet.AmmoType = self.Primary.Ammo
self.Owner:FireBullets( bullet )
self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK )
self.Owner:MuzzleFlash()
self.Owner:SetAnimation( PLAYER_ATTACK1 )
self.Weapon:EmitSound(Sound(self.Primary.Sound))
self.Owner:ViewPunch(Angle( -self.Primary.Recoil, 0, 0 ))
if (self.Primary.TakeAmmoPerBullet) then
self:TakePrimaryAmmo(self.Primary.NumShots)
else
self:TakePrimaryAmmo(1)
end
self:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
end
function SWEP:SecondaryAttack()
if ( !self:CanSecondaryAttack() ) then return end
local bullet = {} -- Set up the shot
bullet.Num = self.Secondary.NumShots
bullet.Src = self.Owner:GetShootPos()
bullet.Dir = self.Owner:GetAimVector()
bullet.Spread = Vector( self.Secondary.Cone / 90, self.Secondary.Cone / 90, 0 )
bullet.Tracer = self.Secondary.Tracer
bullet.Force = self.Secondary.Force
bullet.Damage = self.Secondary.Damage
bullet.AmmoType = self.Secondary.Ammo
self.Owner:FireBullets( bullet )
self.Weapon:SendWeaponAnim( ACT_VM_SECONDARYATTACK )
self.Owner:MuzzleFlash()
self.Weapon:EmitSound(Sound(self.Secondary.Sound))
self.Owner:ViewPunch(Angle( -self.Secondary.Recoil, 0, 0 ))
if (self.Secondary.TakeAmmoPerBullet) then
self:TakeSecondaryAmmo(self.Secondary.NumShots)
else
self:TakeSecondaryAmmo(1)
end
self:SetNextSecondaryFire( CurTime() + self.Secondary.Delay )
end
function SWEP:Think()
end
function SWEP:Reload()
self:DefaultReload(ACT_VM_RELOAD)
return true
end
function SWEP:Deploy()
return true
end
function SWEP:Holster()
return true
end
function SWEP:OnRemove()
end
function SWEP:OnRestore()
end
function SWEP:Precache()
end
function SWEP:OwnerChanged()
end[/lua]
Basically the same concept as the wiki's chair throwing weapon. Here's the [URL="http://wiki.garrysmod.com/page/Chair_Throwing_Gun"]link[/URL].
[QUOTE=wishbone;41670079]Basically the same concept as the wiki's chair throwing weapon. Here's the [URL="http://wiki.garrysmod.com/page/Chair_Throwing_Gun"]link[/URL].[/QUOTE]
Awesome thanks.
Sorry, you need to Log In to post a reply to this thread.