--the folder location and name where the gun sounds are stored --they should be in sound1.ogg, sound2.ogg etc format. local folderlocation = "audiobank\\globalsounds\\custom gunsounds" --the max sounds to load for the random generator to play local max_sounds = 5 --specify all or part of the gun name needed to be used by the player for the sounds (i.e. "colt1911", "magnum" etc) --set to "" if you want to apply to all guns local gun_name = "" local sound_num = 0 dlss = {} function custom_gunsounds_init(e) dlss[e] = {} local a = 0 repeat a = a + 1 dlss[e][a] = 0 repeat dlss[e][a] = dlss[e][a] + 1 until GetGlobalSoundExist(dlss[e][a]) == 0 LoadGlobalSound(folderlocation.."\\sound"..a..".ogg",dlss[e][a]) until a >= max_sounds end function custom_gunsounds_main(e) if g_PlayerGunFired == 1 then if string.find(string.lower(g_PlayerGunName), gun_name) ~= nil or gun_name == "" then for a = 1, max_sounds do if GetGlobalSoundPlaying(dlss[e][a]) == 1 then StopGlobalSound(dlss[e][a]) end sound_num = math.random(1,max_sounds) end if GetGlobalSoundPlaying(sound_num) == 0 then PlayGlobalSound(dlss[e][sound_num]) end return end end end