SWEP that plays sound's

Hey, i got like 12 sound files i want to use (REAL short, <9mb in total) and i was wondering if somebody can make a weapon/gun which simply just plays a sdound file, and when you reload or right click it changes the sound to the next one.

Thanks.

Done.
http://www.garrysmod.org/img/?t=dll&id=74195
Actually you just need to change the sound when you select with right click in the weapon.
It’s not that hard.

:o Thanks man!

Edit:
“Failed to load sound “sound\weegee\weegee1.wav”, file probably missing from disk/repository”#

Tried with my custom files (different file name) And it didnt work, so i tried it without editing and i got that error message in my console,
Yes! Its in the addons folder

Actually,im an idiot,the sound is already the “sound” folder,so there’s no need to add it in the file location

http://www.facepunch.com/fp/emoot/ughh.gif

Replace this
[lua]SSound = Sound (“sound/weegee/weegeeyell.wav”)[/lua]
with this
[lua]SSound = Sound (“weegee/weegeeyell.wav”)[/lua]
Enjoy the sounds.
EDIT:Just copy and paste the full edited weapon.
[lua]
if (SERVER) then
AddCSLuaFile( “shared.lua” )
SWEP.Weight = 5
SWEP.AutoSwitchTo = false
SWEP.AutoSwitchFrom = false
end

if ( CLIENT ) then
SWEP.DrawAmmo = false
SWEP.PrintName = “Sound weapon,LMB to play yourself the sound,Reload to play to a npc and RMB to switch”
SWEP.Author = “Jvs”
SWEP.DrawCrosshair = true
end

SWEP.Category = “”

SWEP.Spawnable = true
SWEP.AdminSpawnable = true

SWEP.ViewModel = “models/weapons/v_pistol.mdl”
SWEP.WorldModel = “models/weapons/w_pistol.mdl”
SWEP.Holdtypecycle = 0

SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = -1
SWEP.Primary.Ammo = “none”
SWEP.Primary.Automatic = false

SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Ammo = false
SWEP.Secondary.Automatic = false

SWEP.Holdtypecycle = 0

local SSound = Sound (“weegee/weegee1.wav”);

function SWEP:PrimaryAttack(ply)
self.Owner:EmitSound(SSound);
end

function SWEP:Reload()
local tr = self.Owner:GetEyeTrace();
if tr.Entity:IsNPC() or tr.Entity:IsPlayer() then
tr.Entity:EmitSound (SSound)
end
end

function SWEP:SecondaryAttack(ply)
if self.Holdtypecycle == 0 then
SSound = Sound (“weegee/weegeeyell.wav”)
self.Owner:PrintMessage( HUD_PRINTCENTER, “MAAAARIOOOO” )
self.Holdtypecycle = self.Holdtypecycle + 1
elseif self.Holdtypecycle == 1 then
SSound = Sound (“weegee/weegee1.wav”)
self.Owner:PrintMessage( HUD_PRINTCENTER, “Mario?” )
self.Holdtypecycle = self.Holdtypecycle + 1
elseif self.Holdtypecycle == 2 then
SSound = Sound (“weegee/weegee2.wav”)
self.Owner:PrintMessage( HUD_PRINTCENTER, “Mario?” )
self.Holdtypecycle = self.Holdtypecycle + 1
elseif self.Holdtypecycle == 3 then
SSound = Sound (“weegee/weegee3.wav”)
self.Owner:PrintMessage( HUD_PRINTCENTER, “Mario?” )
self.Holdtypecycle = self.Holdtypecycle + 1
elseif self.Holdtypecycle == 4 then
SSound = Sound (“weegee/weegee4.wav”)
self.Owner:PrintMessage( HUD_PRINTCENTER, “Mario?” )
self.Holdtypecycle = self.Holdtypecycle + 1
elseif self.Holdtypecycle == 5 then
SSound = Sound (“weegee/weegee5.wav”)
self.Owner:PrintMessage( HUD_PRINTCENTER, “Mario?” )
self.Holdtypecycle = self.Holdtypecycle + 1
elseif self.Holdtypecycle == 6 then
SSound = Sound (“weegee/weegee6.wav”)
self.Owner:PrintMessage( HUD_PRINTCENTER, “Mario?” )
self.Holdtypecycle = self.Holdtypecycle + 1
elseif self.Holdtypecycle == 7 then
SSound = Sound (“weegee/weegee1.wav”)
self.Owner:PrintMessage( HUD_PRINTCENTER, “Mario?” )
self.Holdtypecycle = self.Holdtypecycle + 1
elseif self.Holdtypecycle == 8 then
SSound = Sound (“weegee/weegee2.wav”)
self.Owner:PrintMessage( HUD_PRINTCENTER, “Mario?” )
self.Holdtypecycle = self.Holdtypecycle + 1
elseif self.Holdtypecycle == 9 then
SSound = Sound (“weegee/weegee3.wav”)
self.Owner:PrintMessage( HUD_PRINTCENTER, “Mario?” )
self.Holdtypecycle = self.Holdtypecycle + 1
elseif self.Holdtypecycle == 10 then
SSound = Sound (“weegee/weegee4.wav”)
self.Owner:PrintMessage( HUD_PRINTCENTER, “Mario?” )
self.Holdtypecycle = self.Holdtypecycle + 1
elseif self.Holdtypecycle == 11 then
SSound = Sound (“weegee/weegee5.wav”)
self.Owner:PrintMessage( HUD_PRINTCENTER, “End of the list” )
self.Holdtypecycle = 0
end
end
[/lua]

Works :slight_smile: thanks man

1 problem though, it plays 2 sounds at once sometimes, i think its my problem, still works though :)!