Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Includes */
- #include <sourcemod>
- #include <sdktools>
- /* Plugin Information */
- public Plugin:myinfo = {
- name = "[L4D2] L4D1 sounds restore",
- author = "DeathChaos25",
- description = "Restores L4D1 sounds when playing a L4D1 campaign on L4D2 survivor set",
- version = "1.0",
- url = "1337H4X"
- }
- /* Globals */
- #define DEBUG 1
- #define DEBUG_TAG "L4D1 Sound Restore"
- #define DEBUG_PRINT_FORMAT "[%s] %s"
- new Handle:g_SoundsTrie
- /* Plugin Functions */
- public OnPluginStart()
- {
- g_SoundsTrie = CreateTrie()
- SetupSoundReplacements()
- AddNormalSoundHook(L4D1Sounds_SoundHook);
- }
- // public OnMapStart()
- // Map check coming soon tm
- SetupSoundReplacements()
- {
- /* music sounds */
- SetTrieString(g_SoundsTrie, "music/undeath/death", "music/undeath/death_l4d1")
- SetTrieString(g_SoundsTrie, "music/undeath/leftfordeath", "music/undeath/leftfordeath_l4d1")
- SetTrieString(g_SoundsTrie, "music/terror/iamsocold", "music/terror/iamsocold_l4d1")
- SetTrieString(g_SoundsTrie, "music/terror/puddleofyou", "music/terror/puddleofyou_l4d1")
- SetTrieString(g_SoundsTrie, "music/terror/theend", "music/terror/theend_l4d1")
- SetTrieString(g_SoundsTrie, "music/safe/themonsterwithout", "music/safe/themonsterwithout_l4d1")
- SetTrieString(g_SoundsTrie, "music/safe/themonsterwithout_s", "music/safe/themonsterwithout_l4d1")
- SetTrieString(g_SoundsTrie, "music/tags/iamsocoldhit", "music/tags/iamsocoldhit_l4d1")
- SetTrieString(g_SoundsTrie, "music/tags/leftfordeathhit", "music/tags/leftfordeathhit_l4d1")
- SetTrieString(g_SoundsTrie, "music/tags/puddleofyouhit", "music/tags/puddleofyouhit_l4d1")
- SetTrieString(g_SoundsTrie, "music/the_end/skinonourteeth", "music/the_end/skinonourteeth_l4d1")
- SetTrieString(g_SoundsTrie, "music/the_end/snowballinhell", "music/the_end/snowballinhell_l4d1")
- SetTrieString(g_SoundsTrie, "music/unalive/themonsterwithin", "music/unalive/themonsterwithin_l4d1")
- SetTrieString(g_SoundsTrie, "music/zombat/slayer/lectric/slayer_01a", "music/zombat/slayer/hordeslayer_01")
- SetTrieString(g_SoundsTrie, "music/terror/theend", "music/terror/theend_l4d1")
- SetTrieString(g_SoundsTrie, "music/glimpse/aglimpsofdeath_01", "music/glimpse/aglimpsofhell_01")
- SetTrieString(g_SoundsTrie, "music/glimpse/aglimpsofdeath_02", "music/glimpse/aglimpsofhell_02")
- SetTrieString(g_SoundsTrie, "music/glimpse/aglimpsofdeath_03", "music/glimpse/aglimpsofhell_03")
- }
- public Action:L4D1Sounds_SoundHook(clients[64], &numClients, String:sample[PLATFORM_MAX_PATH], &entity, &channel, &Float:volume, &level, &pitch, &flags)
- {
- if (StrContains(sample, "music", false) != -1)
- {
- decl String:newSample[PLATFORM_MAX_PATH];
- if (!GetTrieString(g_SoundsTrie, sample, newSample, sizeof(newSample)))
- {
- #if DEBUG
- Debug_PrintText("Not replacing sound (\"%s\") as no replacement sound can be found in trie.", sample, newSample)
- #endif
- return Plugin_Continue
- }
- new Handle:pack = CreateDataPack();
- WritePackCell(pack, entity);
- WritePackCell(pack, level);
- WritePackCell(pack, channel);
- WritePackCell(pack, flags);
- WritePackCell(pack, pitch);
- WritePackFloat(pack, volume);
- WritePackString(pack, fileSample);
- CreateTimer(0.0, SoundReplace_Timer, pack, TIMER_FLAG_NO_MAPCHANGE | TIMER_DATA_HNDL_CLOSE);
- volume = 0.0;
- return Plugin_Changed;
- }
- return Plugin_Continue;
- }
- public Action:SoundReplace_Timer(Handle:timer, Handle:pack)
- {
- ResetPack(pack);
- new entity = ReadPackCell(pack);
- new level = ReadPackCell(pack);
- new channel = ReadPackCell(pack);
- new flags = ReadPackCell(pack);
- new pitch = ReadPackCell(pack);
- new Float:volume = ReadPackFloat(pack);
- decl String:sample[PLATFORM_MAX_PATH];
- ReadPackString(pack, sample, PLATFORM_MAX_PATH);
- if (!IsSoundPrecached(sample))
- {
- PrecacheSound(sample, true);
- }
- EmitSoundToAll(sample, entity, channel, level, flags, volume, pitch);
- return Plugin_Stop;
- }
- #if DEBUG
- stock Debug_PrintText(const String:format[], any:...)
- {
- decl String:buffer[256]
- VFormat(buffer, sizeof(buffer), format, 2)
- LogMessage(buffer)
- new AdminId:adminId
- for (new client = 1; client <= MaxClients; client++) {
- if (!IsClientInGame(client) || IsFakeClient(client)) {
- continue
- }
- adminId = GetUserAdmin(client)
- if (adminId == INVALID_ADMIN_ID || !GetAdminFlag(adminId, Admin_Root)) {
- continue
- }
- PrintToChat(client, DEBUG_PRINT_FORMAT, DEBUG_TAG, buffer)
- }
- }
- #endif
Advertisement
Add Comment
Please, Sign In to add comment