diff --git a/Hitmarker/scripting/Hitmarker.sp b/Hitmarker/scripting/Hitmarker.sp index df15d869..f7bf08fe 100644 --- a/Hitmarker/scripting/Hitmarker.sp +++ b/Hitmarker/scripting/Hitmarker.sp @@ -15,11 +15,15 @@ bool g_bShowBossHitmarker[MAXPLAYERS+1]; bool g_bShowZombieHitmarker[MAXPLAYERS+1]; +bool g_bHitmarkerSound[MAXPLAYERS+1]; Handle g_hTimer[MAXPLAYERS+1] = {null,...}; Handle g_hCookie_ShowBossHitmarker; Handle g_hCookie_ShowZombieHitmarker; +Handle g_hCookie_HitmarkerSound; + +//Handle g_hHudText; //---------------------------------------------------------------------------------------------------- // Purpose: @@ -39,9 +43,15 @@ public void OnPluginStart() { g_hCookie_ShowBossHitmarker = RegClientCookie("hitmarker_boss", "", CookieAccess_Private); g_hCookie_ShowZombieHitmarker = RegClientCookie("hitmarker_zombie", "", CookieAccess_Private); + g_hCookie_HitmarkerSound = RegClientCookie("hitmarker_sound", "", CookieAccess_Private); + //g_hHudText = CreateHudSynchronizer(); + + RegConsoleCmd("sm_hm", OnHitmarkerSettings); + RegConsoleCmd("sm_hitmarker", OnHitmarkerSettings); RegConsoleCmd("sm_bhm", OnToggleBossHitmarker); RegConsoleCmd("sm_zhm", OnToggleZombieHitmarker); + RegConsoleCmd("sm_hmsound", OnToggleHitmarkerSound); SetCookieMenuItem(MenuHandler_CookieMenu, 0, "Hitmarker"); @@ -57,6 +67,9 @@ public void OnMapStart() PrecacheGeneric("overlays/nano/hitmarker.vmt", true); AddFileToDownloadsTable("materials/overlays/nano/hitmarker.vtf"); AddFileToDownloadsTable("materials/overlays/nano/hitmarker.vmt"); + + PrecacheSound("unloze/hm.mp3"); + AddFileToDownloadsTable("sound/unloze/hm.mp3"); } //---------------------------------------------------------------------------------------------------- @@ -78,6 +91,13 @@ public void OnClientCookiesCached(int client) g_bShowZombieHitmarker[client] = true; else g_bShowZombieHitmarker[client] = false; + + GetClientCookie(client, g_hCookie_HitmarkerSound, sBuffer, sizeof(sBuffer)); + + if (sBuffer[0]) + g_bHitmarkerSound[client] = true; + else + g_bHitmarkerSound[client] = false; } //---------------------------------------------------------------------------------------------------- @@ -87,6 +107,16 @@ public void OnClientDisconnect(int client) { g_bShowBossHitmarker[client] = false; g_bShowZombieHitmarker[client] = false; + g_bHitmarkerSound[client] = false; +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public Action OnHitmarkerSettings(int client, int args) +{ + ShowSettingsMenu(client); + return Plugin_Handled; } //---------------------------------------------------------------------------------------------------- @@ -129,6 +159,26 @@ public void ToggleZombieHitmarker(int client) CPrintToChat(client, "{cyan}[Hitmarker] {white}%s", g_bShowZombieHitmarker[client] ? "Zombie Hitmarker Enabled" : "Zombie Hitmarker Disabled"); } +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public Action OnToggleHitmarkerSound(int client, int args) +{ + ToggleHitmarkerSound(client); + return Plugin_Handled; +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void ToggleHitmarkerSound(int client) +{ + g_bHitmarkerSound[client] = !g_bHitmarkerSound[client]; + SetClientCookie(client, g_hCookie_HitmarkerSound, g_bHitmarkerSound[client] ? "1" : ""); + + CPrintToChat(client, "{cyan}[Hitmarker] {white}%s", g_bHitmarkerSound[client] ? "Hitmarker Sound Enabled" : "Hitmarker Sound Disabled"); +} + //---------------------------------------------------------------------------------------------------- // Purpose: //---------------------------------------------------------------------------------------------------- @@ -146,6 +196,9 @@ public void ShowSettingsMenu(int client) Format(sBuffer, sizeof(sBuffer), "Zombie Hitmarker: %s", g_bShowZombieHitmarker[client] ? "Enabled" : "Disabled"); menu.AddItem("1", sBuffer); + Format(sBuffer, sizeof(sBuffer), "Hitmarker Sound: %s", g_bHitmarkerSound[client] ? "Enabled" : "Disabled"); + menu.AddItem("2", sBuffer); + menu.ExitBackButton = true; menu.Display(client, MENU_TIME_FOREVER); @@ -182,6 +235,7 @@ public int MenuHandler_MainMenu(Menu menu, MenuAction action, int client, int se { case(0): ToggleBossHitmarker(client); case(1): ToggleZombieHitmarker(client); + case(2): ToggleHitmarkerSound(client); } ShowSettingsMenu(client); @@ -206,7 +260,11 @@ public void OnBossDamaged(any Boss, any Config, int client, float damage) return; if (g_bShowBossHitmarker[client]) + { + //SetHudTextParams(-1.0, -1.0, 0.3, 255, 0, 0, 255, 0, 0.0, 0.0, 0.0); + //ShowSyncHudText(client, g_hHudText, "∷"); ShowOverlay(client); + } for (int spec = 1; spec <= MaxClients; spec++) { @@ -217,7 +275,11 @@ public void OnBossDamaged(any Boss, any Config, int client, float damage) int specTarget = GetClientSpectatorTarget(spec); if ((specMode == SPECMODE_FIRSTPERSON) && specTarget == client) + { + //SetHudTextParams(-1.0, -1.0, 0.3, 255, 0, 0, 255, 0, 0.0, 0.0, 0.0); + //ShowSyncHudText(spec, g_hHudText, "∷"); ShowOverlay(spec); + } } } @@ -236,7 +298,11 @@ public void OnClientHurt(Event hEvent, const char[] sEvent, bool bDontBroadcast) return; if (g_bShowZombieHitmarker[client]) + { + //SetHudTextParams(-1.0, -1.0, 0.3, 255, 0, 0, 255, 0, 0.0, 0.0, 0.0); + //ShowSyncHudText(client, g_hHudText, "∷"); ShowOverlay(client); + } for (int spec = 1; spec <= MaxClients; spec++) { @@ -247,7 +313,11 @@ public void OnClientHurt(Event hEvent, const char[] sEvent, bool bDontBroadcast) int specTarget = GetClientSpectatorTarget(spec); if (specMode == SPECMODE_FIRSTPERSON && specTarget == client) + { + //SetHudTextParams(-1.0, -1.0, 0.3, 255, 0, 0, 255, 0, 0.0, 0.0, 0.0); + //ShowSyncHudText(spec, g_hHudText, "∷"); ShowOverlay(spec); + } } } @@ -257,6 +327,9 @@ public void OnClientHurt(Event hEvent, const char[] sEvent, bool bDontBroadcast) //---------------------------------------------------------------------------------------------------- public void ShowOverlay(int client) { + if (g_bHitmarkerSound[client]) + EmitSoundToClient(client, "unloze/hm.mp3", .volume=1.0); + if (g_hTimer[client] != null) { delete g_hTimer[client]; diff --git a/Hitmarker/sound/unloze/hm.mp3 b/Hitmarker/sound/unloze/hm.mp3 new file mode 100644 index 00000000..7fd1e2c2 Binary files /dev/null and b/Hitmarker/sound/unloze/hm.mp3 differ