Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* *
- * RoundSound BY TUMMIETUM (TUMTUM) and modified by SHARIVAN from ΖмBя.™ Clan
- * -------------------------
- * Changelog Original Roundsound++ by ANTiCHRiST
- * -------------------------
- * by TanaToS aka ANTiCHRiST
- */
- #include <sourcemod>
- #include <sdktools>
- #include <smlib>
- #pragma semicolon 1
- #define PLUGIN_VERSION "1.2.0"
- #define MAX_SOUND_PER_TEAM 256
- #define MAX_FILE_NAME_LENGTH 256
- new t_win_snd_count;
- new String:t_win_snd[MAX_SOUND_PER_TEAM][MAX_FILE_NAME_LENGTH];
- new ct_win_snd_count;
- new String:ct_win_snd[MAX_SOUND_PER_TEAM][MAX_FILE_NAME_LENGTH];
- new Handle:g_hEnabled = INVALID_HANDLE;
- new bool:g_bEnabled = true;
- public Plugin:myinfo = {
- name = "Round Sound CS:GO",
- author = "ANTiCHRiST Edited by TumTum, SilentBr from ΖмBя.™ Clan and SHARIVAN from ΖмBя.™ Clan",
- description = "Plays a Sound at RoundEnd.",
- version = PLUGIN_VERSION,
- url = "http://www.zmbrasil.com.br"
- };
- public OnPluginStart() {
- CreateConVar("sm_roundsound_version", PLUGIN_VERSION, "Versão.", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
- g_hEnabled = CreateConVar("roundsound_enable", "1", "Habilita ou desabilita este plugin.", FCVAR_PLUGIN|FCVAR_NOTIFY);
- AutoExecConfig(true, "roundsound_zmbr");
- HookEvent("round_end", OnRoundEnd);
- HookConVarChange(g_hEnabled, OnConVarChanged);
- t_win_snd_count = 0;
- ct_win_snd_count = 0;
- }
- public OnPluginEnd() {
- UnhookEvent("round_end", OnRoundEnd);
- UnhookConVarChange(g_hEnabled, OnConVarChanged);
- }
- public OnMapStart() {
- t_win_snd_count = 0;
- ct_win_snd_count = 0;
- new Handle:hFile = CreateKeyValues("roundsound");
- KvSetEscapeSequences(hFile, true);
- decl String:sPath[PLATFORM_MAX_PATH];
- BuildPath(Path_SM, sPath, sizeof(sPath), "configs/roundsound.cfg");
- if (!FileExists(sPath)) {
- LogMessage("Config file '%s' not found.", sPath);
- return;
- }
- if (!FileToKeyValues(hFile, sPath)) {
- LogError("Error on loading key values config file '%s'.", sPath);
- return;
- }
- decl String:soundName[MAX_FILE_NAME_LENGTH];
- if (KvJumpToKey(hFile, "terrorists", false)) {
- KvGotoFirstSubKey(hFile, false);
- do {
- KvGetString(hFile, NULL_STRING, soundName, sizeof(soundName));
- if (strlen(soundName) == 0)
- continue;
- AddTSound(soundName);
- } while (KvGotoNextKey(hFile, false));
- }
- KvRewind(hFile);
- if (KvJumpToKey(hFile, "counter-terrorists", false)) {
- KvGotoFirstSubKey(hFile, false);
- do {
- KvGetString(hFile, NULL_STRING, soundName, sizeof(soundName));
- if (strlen(soundName) == 0)
- continue;
- AddCTSound(soundName);
- } while (KvGotoNextKey(hFile, false));
- }
- CloseHandle(hFile);
- }
- public OnConfigsExecuted() {
- g_bEnabled = GetConVarBool(g_hEnabled);
- }
- public OnRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) {
- if (!g_bEnabled)
- return;
- SetRandomSeed(GetTime());
- new winner = GetEventInt(event, "winner");
- switch (winner) {
- case 2: {
- new random = GetRandomInt(0, t_win_snd_count - 1);
- PlaySoundToAll(t_win_snd[random]);
- }
- case 3: {
- new random = GetRandomInt(0, ct_win_snd_count - 1);
- PlaySoundToAll(ct_win_snd[random]);
- }
- }
- }
- public OnConVarChanged(Handle:convar, const String:oldValue[], const String:newValue[]) {
- if (convar == g_hEnabled)
- g_bEnabled = GetConVarBool(g_hEnabled);
- }
- AddCTSound(const String:soundName[]) {
- decl String:soundFile1[MAX_FILE_NAME_LENGTH];
- Format(soundFile1, sizeof(soundFile1), "roundsound/%s", soundName);
- decl String:soundFile2[MAX_FILE_NAME_LENGTH];
- Format(soundFile2, sizeof(soundFile2), "sound/%s", soundFile1);
- if (FileExists(soundFile2)) {
- strcopy(ct_win_snd[ct_win_snd_count++], MAX_FILE_NAME_LENGTH, soundName);
- AddFileToDownloadsTable(soundFile2);
- PrecacheSound(soundFile1, true);
- LogMessage("Counter-Terrorist sound added: %s", soundName);
- } else
- LogError("Counter-Terrorist sound '%s' not found.", soundName);
- }
- AddTSound(const String:soundName[]) {
- decl String:soundFile1[MAX_FILE_NAME_LENGTH];
- Format(soundFile1, sizeof(soundFile1), "roundsound/%s", soundName);
- decl String:soundFile2[MAX_FILE_NAME_LENGTH];
- Format(soundFile2, sizeof(soundFile2), "sound/%s", soundFile1);
- if (FileExists(soundFile2)) {
- strcopy(t_win_snd[t_win_snd_count++], MAX_FILE_NAME_LENGTH, soundName);
- AddFileToDownloadsTable(soundFile2);
- PrecacheSound(soundFile1, true);
- LogMessage("Terrorist sound added: %s", soundName);
- } else
- LogError("Terrorist sound '%s' not found.", soundName);
- }
- PlaySoundToAll(const String:soundName[]) {
- for (new client = 1; client <= MaxClients; client++)
- if(Client_IsIngame(client) && !IsFakeClient(client))
- ClientCommand(client, "play *roundsound/%s", soundName);
- }
Advertisement
Add Comment
Please, Sign In to add comment