• How to set a guns reload sounds
    4 replies, posted
Hello, I have got a custom weapon here, just a basic weapon but when I reload it, the reload sounds do not play however, the shoot sound does. After a little research I found this: [lua] local h3 = {} h3["channel"] = CHAN_WEAPON h3["level"] = SNDLVL_GUNFIRE h3["sound"] = "weapons/spas/spas12-1.wav" h3["name"] = "Weapon_H3.Single" h3["script"] = "scripts/sounds/hl2_game_sounds_weapons.txt" [/lua] This was in the guns shared.lua file, how would I go about using this to fix my guns reload sounds not working? Or is there any other alternatives?
[QUOTE=smithy285;41022517]Hello, I have got a custom weapon here, just a basic weapon but when I reload it, the reload sounds do not play however, the shoot sound does. After a little research I found this: [lua] local h3 = {} h3["channel"] = CHAN_WEAPON h3["level"] = SNDLVL_GUNFIRE h3["sound"] = "weapons/spas/spas12-1.wav" h3["name"] = "Weapon_H3.Single" h3["script"] = "scripts/sounds/hl2_game_sounds_weapons.txt" [/lua] This was in the guns shared.lua file, how would I go about using this to fix my guns reload sounds not working? Or is there any other alternatives?[/QUOTE] [CODE]function SWEP:Reload() self:EmitSound("Sound.wav", 75, 100) end[/CODE] I think this is how you create a reload sound.
[QUOTE=FreeTacos.exe;41022598][CODE]function SWEP:Reload() self:EmitSound("Sound.wav", 75, 100) end[/CODE] I think this is how you create a reload sound.[/QUOTE] I understand that, but how would I create a delay between sounds? I am come from a background from lots of Python coding and in that I always used something like time.wait(number in seconds) but I understand that is not in lua.
[QUOTE=smithy285;41022778]I understand that, but how would I create a delay between sounds? I am come from a background from lots of Python coding and in that I always used something like time.wait(number in seconds) but I understand that is not in lua.[/QUOTE] You could create a time like so [CODE]function SWEP:Reload() timer.Create( "reload_timer", "InsertDelayTimeHere", 1, function() self:EmitSound("Sound.wav", 75, 100) end) end[/CODE] Keep the 1 in the "timer.Create" code or else if you put it to another number, for example 5, the timer will keep running 5 times then it will stop.
[QUOTE=FreeTacos.exe;41025563]You could create a time like so [CODE]function SWEP:Reload() timer.Create( "reload_timer", "InsertDelayTimeHere", 1, function() self:EmitSound("Sound.wav", 75, 100) end) end[/CODE] Keep the 1 in the "timer.Create" code or else if you put it to another number, for example 5, the timer will keep running 5 times then it will stop.[/QUOTE] Thanks very much, exactly what I was looking for!
Sorry, you need to Log In to post a reply to this thread.