Hi,
I'm trying to put 2 sounds (I shoot one time and I hear a sound, I shoot again and I hear other sound) to my SWEP, I have this
[QUOTE]BarretSounds = {
"Weapons/m82a3/BF3M82A3-1.wav",
"Weapons/m82a3/BF3M82A3-2.wav"
}
SWEP.Primary.Sound = Sound (table.Random(BarretSounds))[/QUOTE]
The problem is, I only hear just one sound of the above, so what thing is wrong?
PD: First post :3
PDD: Sorry for my poor english, I'm latin american [IMG]http://o1.t26.net/images/smiles/wink.gif[/IMG]
The reason is you are using table.Random() so its getting one random string from the table. Also I think that it would only pick one sound when the entity is initialized unless SWEP.Primary.Sound is defined every shot.
[QUOTE=mrchris75;38914821]The reason is you are using table.Random() so its getting one random string from the table. Also I think that it would only pick one sound when the entity is initialized unless SWEP.Primary.Sound is defined every shot.[/QUOTE]
So, how i can define 2 different shots(sounds)?
bump.
Any idea? plz
Put the table.random(derp) thing in the shoot function itself. This way it will randomize the sound each time you shoot a bullet.
So it looks like this
[CODE]
function SWEP:PrimaryAttack()
if ( !self:CanPrimaryAttack() ) then return end
[B] self:EmitSound(table.Random(your_table_name)) [/B]
self:ShootBullet( 150, 1, 0.01 )
self:TakePrimaryAmmo( 1 )
self.Owner:ViewPunch( Angle( -1, 0, 0 ) )
end
[/CODE]
[QUOTE=Failure;38923183]Put the table.random(derp) thing in the shoot function itself. This way it will randomize the sound each time you shoot a bullet.
So it looks like this
[CODE]
function SWEP:PrimaryAttack()
if ( !self:CanPrimaryAttack() ) then return end
[B] self:EmitSound(table.Random(your_table_name)) [/B]
self:ShootBullet( 150, 1, 0.01 )
self:TakePrimaryAmmo( 1 )
self.Owner:ViewPunch( Angle( -1, 0, 0 ) )
end
[/CODE][/QUOTE]
Thank you very much :D, that is very helpful [IMG]http://o1.t26.net/images/smiles/alabama.gif[/IMG] was difficult to put the code, because I has to write the code on my "base" and that affected my others SWEPs but i already fixed it [IMG]http://o1.t26.net/images/smiles/cool.gif[/IMG]
Sorry, you need to Log In to post a reply to this thread.