|
|
|
@@ -18,6 +18,11 @@ bool g_bShowZombieHitmarker[MAXPLAYERS+1];
|
|
|
|
|
bool g_bHitmarkerSound[MAXPLAYERS+1];
|
|
|
|
|
|
|
|
|
|
int g_iHitmarkerSoundVolume[MAXPLAYERS+1] = {100,...};
|
|
|
|
|
int g_iHitmarkerSkin[MAXPLAYERS+1];
|
|
|
|
|
|
|
|
|
|
#define MAXIMUMSKINS 6
|
|
|
|
|
char g_sHitmarkerSkins[MAXIMUMSKINS][PLATFORM_MAX_PATH];
|
|
|
|
|
char g_sHitmarkerSkinsNames[MAXIMUMSKINS][PLATFORM_MAX_PATH];
|
|
|
|
|
|
|
|
|
|
Handle g_hTimer[MAXPLAYERS+1] = {null,...};
|
|
|
|
|
|
|
|
|
@@ -25,18 +30,17 @@ Handle g_hCookie_ShowBossHitmarker;
|
|
|
|
|
Handle g_hCookie_ShowZombieHitmarker;
|
|
|
|
|
Handle g_hCookie_HitmarkerSound;
|
|
|
|
|
Handle g_hCookie_HitmarkerSoundVolume;
|
|
|
|
|
|
|
|
|
|
//Handle g_hHudText;
|
|
|
|
|
Handle g_hCookie_HitmarkerSkin;
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
|
|
|
// Purpose:
|
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
|
|
|
public Plugin myinfo =
|
|
|
|
|
{
|
|
|
|
|
name = "Htimarker",
|
|
|
|
|
name = "Hitmarker",
|
|
|
|
|
author = "Neon & Nano",
|
|
|
|
|
description = "Players can enable or disable their hitmarkers while shooting zombies or bosses",
|
|
|
|
|
version = "1.0.0",
|
|
|
|
|
version = "2.0.0",
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
|
|
@@ -48,8 +52,7 @@ public void OnPluginStart()
|
|
|
|
|
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();
|
|
|
|
|
g_hCookie_HitmarkerSkin = RegClientCookie("hitmarker_skin", "", CookieAccess_Private);
|
|
|
|
|
|
|
|
|
|
RegConsoleCmd("sm_hm", OnHitmarkerSettings);
|
|
|
|
|
RegConsoleCmd("sm_hitmarker", OnHitmarkerSettings);
|
|
|
|
@@ -59,7 +62,7 @@ public void OnPluginStart()
|
|
|
|
|
|
|
|
|
|
SetCookieMenuItem(MenuHandler_CookieMenu, 0, "Hitmarker");
|
|
|
|
|
|
|
|
|
|
HookEvent("player_hurt", OnClientHurt);
|
|
|
|
|
HookEvent("player_hurt", OnClientHurt);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
|
|
@@ -67,10 +70,66 @@ public void OnPluginStart()
|
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
|
|
|
public void OnMapStart()
|
|
|
|
|
{
|
|
|
|
|
PrecacheGeneric("overlays/nano/hitmarker.vtf", true);
|
|
|
|
|
PrecacheGeneric("overlays/nano/hitmarker.vmt", true);
|
|
|
|
|
AddFileToDownloadsTable("materials/overlays/nano/hitmarker.vtf");
|
|
|
|
|
AddFileToDownloadsTable("materials/overlays/nano/hitmarker.vmt");
|
|
|
|
|
for (int i = 0; i < MAXIMUMSKINS; i++)
|
|
|
|
|
{
|
|
|
|
|
g_sHitmarkerSkins[i] = "";
|
|
|
|
|
g_sHitmarkerSkinsNames[i] = "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char sConfigFile[PLATFORM_MAX_PATH];
|
|
|
|
|
BuildPath(Path_SM, sConfigFile, sizeof(sConfigFile), "configs/Hitmarkers.cfg");
|
|
|
|
|
|
|
|
|
|
if (!FileExists(sConfigFile))
|
|
|
|
|
SetFailState("Could not find: \"%s\"", sConfigFile);
|
|
|
|
|
|
|
|
|
|
KeyValues Hitmarkers = new KeyValues("Hitmarkers");
|
|
|
|
|
|
|
|
|
|
if (!Hitmarkers.ImportFromFile(sConfigFile))
|
|
|
|
|
{
|
|
|
|
|
delete Hitmarkers;
|
|
|
|
|
SetFailState("ImportFromFile() failed!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!Hitmarkers.GotoFirstSubKey())
|
|
|
|
|
{
|
|
|
|
|
delete Hitmarkers;
|
|
|
|
|
SetFailState("Unable to goto first sub key in: \"%s\"", sConfigFile);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
char sPath[PLATFORM_MAX_PATH];
|
|
|
|
|
Hitmarkers.GetString("Path", sPath, sizeof(sPath), "error");
|
|
|
|
|
if (StrEqual(sPath, "error"))
|
|
|
|
|
{
|
|
|
|
|
delete Hitmarkers;
|
|
|
|
|
SetFailState("Unable to read Path");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char sName[32];
|
|
|
|
|
Hitmarkers.GetString("Name", sName, sizeof(sName), "error");
|
|
|
|
|
if (StrEqual(sName, "error"))
|
|
|
|
|
{
|
|
|
|
|
delete Hitmarkers;
|
|
|
|
|
SetFailState("Unable to read Name");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char sBuffer[PLATFORM_MAX_PATH];
|
|
|
|
|
|
|
|
|
|
Format(sBuffer, sizeof(sBuffer), "materials/%s.vmt", sPath);
|
|
|
|
|
PrecacheGeneric(sBuffer, true);
|
|
|
|
|
AddFileToDownloadsTable(sBuffer);
|
|
|
|
|
|
|
|
|
|
Format(sBuffer, sizeof(sBuffer), "materials/%s.vtf", sPath);
|
|
|
|
|
PrecacheGeneric(sBuffer, true);
|
|
|
|
|
AddFileToDownloadsTable(sBuffer);
|
|
|
|
|
|
|
|
|
|
g_sHitmarkerSkins[i] = sPath;
|
|
|
|
|
g_sHitmarkerSkinsNames[i] = sName;
|
|
|
|
|
i++;
|
|
|
|
|
} while(Hitmarkers.GotoNextKey());
|
|
|
|
|
delete Hitmarkers;
|
|
|
|
|
|
|
|
|
|
PrecacheSound("unloze/hm_v3.mp3");
|
|
|
|
|
AddFileToDownloadsTable("sound/unloze/hm_v3.mp3");
|
|
|
|
@@ -81,34 +140,46 @@ public void OnMapStart()
|
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
|
|
|
public void OnClientCookiesCached(int client)
|
|
|
|
|
{
|
|
|
|
|
char sBuffer[4];
|
|
|
|
|
GetClientCookie(client, g_hCookie_ShowBossHitmarker, sBuffer, sizeof(sBuffer));
|
|
|
|
|
char sBuffer[PLATFORM_MAX_PATH];
|
|
|
|
|
|
|
|
|
|
GetClientCookie(client, g_hCookie_ShowBossHitmarker, sBuffer, sizeof(sBuffer));
|
|
|
|
|
if (sBuffer[0])
|
|
|
|
|
g_bShowBossHitmarker[client] = true;
|
|
|
|
|
else
|
|
|
|
|
g_bShowBossHitmarker[client] = false;
|
|
|
|
|
|
|
|
|
|
GetClientCookie(client, g_hCookie_ShowZombieHitmarker, sBuffer, sizeof(sBuffer));
|
|
|
|
|
|
|
|
|
|
if (sBuffer[0])
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
GetClientCookie(client, g_hCookie_HitmarkerSoundVolume, sBuffer, sizeof(sBuffer));
|
|
|
|
|
|
|
|
|
|
if (sBuffer[0])
|
|
|
|
|
g_iHitmarkerSoundVolume[client] = StringToInt(sBuffer);
|
|
|
|
|
else
|
|
|
|
|
g_iHitmarkerSoundVolume[client] = 100;
|
|
|
|
|
|
|
|
|
|
GetClientCookie(client, g_hCookie_HitmarkerSkin, sBuffer, sizeof(sBuffer));
|
|
|
|
|
if (sBuffer[0])
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < MAXIMUMSKINS; i++)
|
|
|
|
|
{
|
|
|
|
|
if (StrEqual(g_sHitmarkerSkins[i], sBuffer))
|
|
|
|
|
{
|
|
|
|
|
g_iHitmarkerSkin[client] = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
g_iHitmarkerSkin[client] = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
|
|
@@ -120,6 +191,7 @@ public void OnClientDisconnect(int client)
|
|
|
|
|
g_bShowZombieHitmarker[client] = false;
|
|
|
|
|
g_bHitmarkerSound[client] = false;
|
|
|
|
|
g_iHitmarkerSoundVolume[client] = 100;
|
|
|
|
|
g_iHitmarkerSkin[client] = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
|
|
@@ -149,6 +221,9 @@ public void ToggleBossHitmarker(int 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");
|
|
|
|
|
|
|
|
|
|
if (g_bShowBossHitmarker[client])
|
|
|
|
|
ShowOverlay(client, 2.0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
|
|
@@ -169,6 +244,9 @@ public void ToggleZombieHitmarker(int 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");
|
|
|
|
|
|
|
|
|
|
if (g_bShowZombieHitmarker[client])
|
|
|
|
|
ShowOverlay(client, 2.0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
|
|
@@ -189,6 +267,9 @@ public void ToggleHitmarkerSound(int 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");
|
|
|
|
|
|
|
|
|
|
if (g_bHitmarkerSound[client])
|
|
|
|
|
ShowOverlay(client, 2.0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
|
|
@@ -206,7 +287,22 @@ public void ToggleHitmarkerSoundVolume(int client)
|
|
|
|
|
|
|
|
|
|
SetClientCookie(client, g_hCookie_HitmarkerSoundVolume, sBuffer);
|
|
|
|
|
|
|
|
|
|
//CPrintToChat(client, "{cyan}[Hitmarker] {white}Hitmarker Sound Volume: %d\%", g_iHitmarkerSoundVolume[client]);
|
|
|
|
|
ShowOverlay(client, 2.0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
|
|
|
// Purpose:
|
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
|
|
|
public void ToggleHitmarkerSkin(int client)
|
|
|
|
|
{
|
|
|
|
|
g_iHitmarkerSkin[client]++;
|
|
|
|
|
|
|
|
|
|
if (StrEqual(g_sHitmarkerSkins[g_iHitmarkerSkin[client]], ""))
|
|
|
|
|
g_iHitmarkerSkin[client] = 0;
|
|
|
|
|
|
|
|
|
|
SetClientCookie(client, g_hCookie_HitmarkerSkin, g_sHitmarkerSkins[g_iHitmarkerSkin[client]]);
|
|
|
|
|
|
|
|
|
|
ShowOverlay(client, 2.0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
|
|
@@ -232,6 +328,9 @@ public void ShowSettingsMenu(int client)
|
|
|
|
|
Format(sBuffer, sizeof(sBuffer), "Hitmarker Sound Volume: %d\%", g_iHitmarkerSoundVolume[client]);
|
|
|
|
|
menu.AddItem("3", sBuffer);
|
|
|
|
|
|
|
|
|
|
Format(sBuffer, sizeof(sBuffer), "Hitmarker Skin: %s", g_sHitmarkerSkinsNames[g_iHitmarkerSkin[client]]);
|
|
|
|
|
menu.AddItem("4", sBuffer);
|
|
|
|
|
|
|
|
|
|
menu.ExitBackButton = true;
|
|
|
|
|
|
|
|
|
|
menu.Display(client, MENU_TIME_FOREVER);
|
|
|
|
@@ -270,6 +369,7 @@ public int MenuHandler_MainMenu(Menu menu, MenuAction action, int client, int se
|
|
|
|
|
case(1): ToggleZombieHitmarker(client);
|
|
|
|
|
case(2): ToggleHitmarkerSound(client);
|
|
|
|
|
case(3): ToggleHitmarkerSoundVolume(client);
|
|
|
|
|
case(4): ToggleHitmarkerSkin(client);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ShowSettingsMenu(client);
|
|
|
|
@@ -294,11 +394,7 @@ public void OnBossDamaged(CBoss Boss, CConfig 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++)
|
|
|
|
|
{
|
|
|
|
@@ -309,11 +405,7 @@ public void OnBossDamaged(CBoss Boss, CConfig 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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -332,11 +424,7 @@ 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++)
|
|
|
|
|
{
|
|
|
|
@@ -347,19 +435,14 @@ 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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
|
|
|
// Purpose:
|
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
|
|
|
public void ShowOverlay(int client)
|
|
|
|
|
void ShowOverlay(int client, float fTime = 0.3)
|
|
|
|
|
{
|
|
|
|
|
if (g_bHitmarkerSound[client])
|
|
|
|
|
{
|
|
|
|
@@ -372,8 +455,8 @@ public void ShowOverlay(int client)
|
|
|
|
|
delete g_hTimer[client];
|
|
|
|
|
g_hTimer[client] = null;
|
|
|
|
|
}
|
|
|
|
|
ClientCommand(client, "r_screenoverlay \"%s\"", "overlays/nano/hitmarker");
|
|
|
|
|
g_hTimer[client] = CreateTimer(0.3, ClearOverlay, client, TIMER_FLAG_NO_MAPCHANGE);
|
|
|
|
|
ClientCommand(client, "r_screenoverlay \"%s\"", g_sHitmarkerSkins[g_iHitmarkerSkin[client]]);
|
|
|
|
|
g_hTimer[client] = CreateTimer(fTime, ClearOverlay, client, TIMER_FLAG_NO_MAPCHANGE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
|
|
|