I'm in the midst of scripting my own SWEP based on the SST Morita rifle. The one I'm currently scripting has a shotgun attachment.
Though I know how to make an SWEP with proper primary fire, I never did learn how to script in secondary fire. I know you need to edit the hooks for it (Most LUA SWEPS leave it blank) but I don't know what to put. As stated above, I'm trying to make it so it fires 6 bullets at once, like a shotgun.
Also, I am using the built in GMOD base. (These weapons are super basic, well, except for the nuke launcher.)
Take from the [url=http://luabin.overvprojects.nl/?path=/gamemodes/base/entities/weapons/weapon_base/]base SWEP[/url].
[lua]
/*---------------------------------------------------------
Name: SWEP:SecondaryAttack( )
Desc: +attack2 has been pressed
---------------------------------------------------------*/
function SWEP:SecondaryAttack()
// Make sure we can shoot first
if ( !self:CanSecondaryAttack() ) then return end
// Play shoot sound
self.Weapon:EmitSound("Weapon_Shotgun.Single")
// Shoot 9 bullets, 150 damage, 0.75 aimcone
self:ShootBullet( 150, 9, 0.2 )
// Remove 1 bullet from our clip
self:TakeSecondaryAmmo( 1 )
// Punch the player's view
self.Owner:ViewPunch( Angle( -10, 0, 0 ) )
end
[/lua]
Sorry, you need to Log In to post a reply to this thread.