Hitmarker: update

This commit is contained in:
neon 2019-09-12 14:31:37 +02:00
parent 38f6bf8bea
commit 544112da92
3 changed files with 43 additions and 6 deletions

View File

@ -17,11 +17,14 @@ bool g_bShowBossHitmarker[MAXPLAYERS+1];
bool g_bShowZombieHitmarker[MAXPLAYERS+1];
bool g_bHitmarkerSound[MAXPLAYERS+1];
int g_iHitmarkerSoundVolume[MAXPLAYERS+1] = {100,...};
Handle g_hTimer[MAXPLAYERS+1] = {null,...};
Handle g_hCookie_ShowBossHitmarker;
Handle g_hCookie_ShowZombieHitmarker;
Handle g_hCookie_HitmarkerSound;
Handle g_hCookie_HitmarkerSoundVolume;
//Handle g_hHudText;
@ -44,6 +47,7 @@ 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_hCookie_HitmarkerSoundVolume = RegClientCookie("hitmarker_sound_volume", "", CookieAccess_Private);
//g_hHudText = CreateHudSynchronizer();
@ -68,8 +72,8 @@ public void OnMapStart()
AddFileToDownloadsTable("materials/overlays/nano/hitmarker.vtf");
AddFileToDownloadsTable("materials/overlays/nano/hitmarker.vmt");
PrecacheSound("unloze/hm.mp3");
AddFileToDownloadsTable("sound/unloze/hm.mp3");
PrecacheSound("unloze/hm_v2.mp3");
AddFileToDownloadsTable("sound/unloze/hm_v2.mp3");
}
//----------------------------------------------------------------------------------------------------
@ -98,6 +102,13 @@ public void OnClientCookiesCached(int client)
g_bHitmarkerSound[client] = true;
else
g_bHitmarkerSound[client] = false;
GetClientCookie(client, g_hCookie_HitmarkerSoundVolume, sBuffer, sizeof(sBuffer));
if (sBuffer[0])
g_iHitmarkerSoundVolume[client] = 100;
else
g_iHitmarkerSoundVolume[client] = StringToInt(sBuffer);
}
//----------------------------------------------------------------------------------------------------
@ -108,6 +119,7 @@ public void OnClientDisconnect(int client)
g_bShowBossHitmarker[client] = false;
g_bShowZombieHitmarker[client] = false;
g_bHitmarkerSound[client] = false;
g_iHitmarkerSoundVolume[client] = 100;
}
//----------------------------------------------------------------------------------------------------
@ -136,7 +148,7 @@ public void ToggleBossHitmarker(int client)
g_bShowBossHitmarker[client] = !g_bShowBossHitmarker[client];
SetClientCookie(client, g_hCookie_ShowBossHitmarker, g_bShowBossHitmarker[client] ? "1" : "");
CPrintToChat(client, "{cyan}[Hitmarker] {white}%s", g_bShowBossHitmarker[client] ? "Boss Hitmarker Enabled." : "Boss Hitmarker Disabled.");
CPrintToChat(client, "{cyan}[Hitmarker] {white}%s.", g_bShowBossHitmarker[client] ? "Boss Hitmarker Enabled" : "Boss Hitmarker Disabled");
}
//----------------------------------------------------------------------------------------------------
@ -156,7 +168,7 @@ public void ToggleZombieHitmarker(int client)
g_bShowZombieHitmarker[client] = !g_bShowZombieHitmarker[client];
SetClientCookie(client, g_hCookie_ShowZombieHitmarker, g_bShowZombieHitmarker[client] ? "1" : "");
CPrintToChat(client, "{cyan}[Hitmarker] {white}%s", g_bShowZombieHitmarker[client] ? "Zombie Hitmarker Enabled." : "Zombie Hitmarker Disabled.");
CPrintToChat(client, "{cyan}[Hitmarker] {white}%s.", g_bShowZombieHitmarker[client] ? "Zombie Hitmarker Enabled" : "Zombie Hitmarker Disabled");
}
//----------------------------------------------------------------------------------------------------
@ -176,7 +188,25 @@ 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.");
CPrintToChat(client, "{cyan}[Hitmarker] {white}%s.", g_bHitmarkerSound[client] ? "Hitmarker Sound Enabled" : "Hitmarker Sound Disabled");
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void ToggleHitmarkerSoundVolume(int client)
{
g_iHitmarkerSoundVolume[client] += 25;
if(g_iHitmarkerSoundVolume[client] > 100)
g_iHitmarkerSoundVolume[client] = 25;
char sBuffer[16];
IntToString(g_iHitmarkerSoundVolume[client], sBuffer, sizeof(sBuffer));
SetClientCookie(client, g_hCookie_HitmarkerSoundVolume, sBuffer);
//CPrintToChat(client, "{cyan}[Hitmarker] {white}Hitmarker Sound Volume: %d\%", g_iHitmarkerSoundVolume[client]);
}
//----------------------------------------------------------------------------------------------------
@ -199,6 +229,9 @@ public void ShowSettingsMenu(int client)
Format(sBuffer, sizeof(sBuffer), "Hitmarker Sound: %s", g_bHitmarkerSound[client] ? "Enabled" : "Disabled");
menu.AddItem("2", sBuffer);
Format(sBuffer, sizeof(sBuffer), "Hitmarker Sound Volume: %d\%", g_iHitmarkerSoundVolume[client]);
menu.AddItem("3", sBuffer);
menu.ExitBackButton = true;
menu.Display(client, MENU_TIME_FOREVER);
@ -236,6 +269,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);
case(3): ToggleHitmarkerSoundVolume(client);
}
ShowSettingsMenu(client);
@ -328,7 +362,10 @@ 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);
{
float fVolume = g_iHitmarkerSoundVolume[client] / 100.0;
EmitSoundToClient(client, "unloze/hm_v2.mp3", .volume=fVolume);
}
if (g_hTimer[client] != null)
{

Binary file not shown.

Binary file not shown.