• How make a weapon make different firing sounds?
    6 replies, posted
If i have a weapon, how do i make fire 2 different sounds at different times? ex if i have an awp with 2 firing sounds, awp1 and awp2, how do I make it so it plays either one instead of the same firing sound? Also, is this possible to do with reloading sounds?
Make a table and put a table.Random were the fire sound would be.
This [lua] local Shootsounds = { "a sound", "a sound here too", "and another sound" } --then in the SWEP.PrimaryAttack function add this local sound = math.random(1, table.getn(Shootsounds)) self.Owner:EmitSound(Shootsounds[sound]) [/lua] Replace the strings in the "Shootsounds" table with your sounds's path
[QUOTE=Loures;22646794]This [lua] local Shootsounds = { "a sound", "a sound here too", "and another sound" } --then in the SWEP.PrimaryAttack function add this local sound = math.random(1, table.getn(Shootsounds)) self.Owner:EmitSound(Shootsounds[sound]) [/lua] Replace the strings in the "Shootsounds" table with your sounds's path[/QUOTE] can you show how a swep would look like with these scripts, because im not sure how it should look like
Meh, just put the [lua] local Shootsounds = { "a sound", "a sound here too", "and another sound" } [/lua] At the beginning of the Lua file and put the rest in the SWEP.PrimaryAttack function
[QUOTE=Loures;22667452]Meh, just put the [lua] local Shootsounds = { "a sound", "a sound here too", "and another sound" } [/lua] At the beginning of the Lua file and put the rest in the SWEP.PrimaryAttack function[/QUOTE] so i replace the bold local Shootsounds = { "[B]a sound[/B]", "[B]a sound here too[/B]", "[B]and another sound[/B]" } with the sounds i want it to randomize, but what do i replace (again, in bold) local Shootsounds = { "a sound", "a sound here too", "and another sound" } --then in the SWEP.PrimaryAttack function add this local sound = math.random(1, table.getn([B]Shootsounds[/B])) self.Owner:EmitSound[B](Shootsounds[sound])[/B] with? do i put the folder where the sounds are located?
Use table.Random(table).
Sorry, you need to Log In to post a reply to this thread.