From fe1dd80c6b8411a1b0497fe348fddc2ef691f4ec Mon Sep 17 00:00:00 2001 From: neon <> Date: Sat, 7 Sep 2019 14:17:16 +0200 Subject: [PATCH] Hitmarker: improvements + sound --- Hitmarker/scripting/Hitmarker.sp | 73 +++++++++++++++++++++++++++++++ Hitmarker/sound/unloze/hm.mp3 | Bin 0 -> 2088 bytes 2 files changed, 73 insertions(+) create mode 100644 Hitmarker/sound/unloze/hm.mp3 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 0000000000000000000000000000000000000000..7fd1e2c261c0fd4594b8ced1f9a87704138bbfc8 GIT binary patch literal 2088 zcmezWdqN5W0pOXJmJd|I55z1C3>+E^4mdyqE^q)B_>T(!?XvW7^mR4Xv$QN?Tm^EW zo;(ACNP`MXpdSN61IQhh^p7#Jmjc%>~n8h{=* zX$BHI&z59de8u1s)?femZ;t|lf|GLX%_k@C{r_Km|Br+tN5}5nHZzSfkJNwvq2~Af zh)eAM-!}~y99fi<>~{kNe(&D@`;H3`2&qtZF+>^c6I^3lL!Cg&BaF8P*TUmwMDX6>v?d@g5sFKP4{@%accKG-*@b9(;&|9{KF z|NsB-t?6oe_mGB-NY}65em*yd>0kMD@0< z*u{Uj3=9!A6Fxeu)?qMexMIt4G5(x!!2?c53w6dD>%!+N{r^2FMV)~yG%fC5>H}b8 z@G2Z&U=a759kp{MkOzsN!~b7>elSP4`N=Qm=~p?j*53dBxp3{uHFv|c;%qakRqp>x zpFM}y<-vW6{?%_+o%+4*|Nn36uXY_x-kP{?z4_I-Q)i_nzr1y8`Tzg+|34Q*NKIXL zb#C0+@T|VAQFjkbDL1)v{tqx8z1v?_yLI>5yt{R4N^joVH!X5m{qu@rUw;4-4THp_ z1v8FG{G7%-?Odj^fQOrf1bZY$10Q>sqHL&iB%Xns`<$Xx7#d%uIg#p~Uf`z{1PyE*kp(WDRz*o{^OR5_*OI#r6N`H5_gD z-*m#cmro-ou~hNcq$L|QRoSiopDc<9Vwxn$#hyt4(^XIAmBm`lIlce?$2}}Y4s7Zg%;&9E`&rw}*70ERn)Nia z`m5+#S6A2Bp?_Ul8#kEoujgxsux)!X*^N8UJ^qi-QW=kxTW&fX*E+Cat8vk?!_EbP zpcqo_`TRQRV7ep&I14>sVC1^$x5$AZ`vx$E8i3{6rB#8~zppyAYSq6pI+s?*U%TtD zHD$KgYMr~~T5HZ+*N!{8YW>lZYU{2AY`nB+(V_(h-D{Mc<{xa(4gH@w>9o$KNRR(& zVO$at3W?6lEHcUq3=-z@My9M;*x1CzAz<+$<0*3{Qb#$f5rO14AY-t#W|!5Ca1v U5G?_6flP1=VQ3l^pkoLC0OiQLrT_o{ literal 0 HcmV?d00001