forked from UNLOZE/sm-plugins
added cvars for being enabled/disabled for specific maps
This commit is contained in:
@@ -38,6 +38,7 @@ Handle g_hCookie_HitmarkerSoundVolume;
|
||||
Handle g_hCookie_HitmarkerSkin;
|
||||
|
||||
ConVar g_hCVar_Debug;
|
||||
ConVar g_hCVar_HitmarkerEnabled;
|
||||
|
||||
bool g_bLate;
|
||||
|
||||
@@ -87,7 +88,9 @@ public void OnPluginStart()
|
||||
g_hCookie_HitmarkerSkin = RegClientCookie("hitmarker_skin", "", CookieAccess_Private);
|
||||
|
||||
g_hCVar_Debug = CreateConVar("sm_hitmarker_debug", "0", "", FCVAR_NONE, true, 0.0, true, 1.0);
|
||||
AutoExecConfig();
|
||||
g_hCVar_HitmarkerEnabled = CreateConVar("sm_hitmarker_enabled", "1", "", FCVAR_NONE, true, 0.0, true, 1.0);
|
||||
g_hCVar_HitmarkerEnabled.AddChangeHook(OnConVarChanged);
|
||||
AutoExecConfig(true);
|
||||
|
||||
RegConsoleCmd("sm_hm", OnHitmarkerSettings);
|
||||
RegConsoleCmd("sm_hitmarker", OnHitmarkerSettings);
|
||||
@@ -109,6 +112,14 @@ public void OnPluginStart()
|
||||
}
|
||||
}
|
||||
|
||||
public void OnConVarChanged(ConVar convar, const char[] oldValue, const char[] newValue)
|
||||
{
|
||||
if(g_hCVar_HitmarkerEnabled.BoolValue)
|
||||
CPrintToChatAll("{cyan}[Hitmarker] {white}has been allowed.");
|
||||
else
|
||||
CPrintToChatAll("{cyan}[Hitmarker] {white}has been disabled.");
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
@@ -120,6 +131,11 @@ public void OnMapStart()
|
||||
g_sHitmarkerSkinsNames[i] = "";
|
||||
}
|
||||
|
||||
if(!g_hCVar_HitmarkerEnabled.BoolValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
char sConfigFile[PLATFORM_MAX_PATH];
|
||||
BuildPath(Path_SM, sConfigFile, sizeof(sConfigFile), "configs/Hitmarkers.cfg");
|
||||
|
||||
@@ -184,6 +200,11 @@ public void OnMapStart()
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnClientCookiesCached(int client)
|
||||
{
|
||||
if(!g_hCVar_HitmarkerEnabled.BoolValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
char sBuffer[PLATFORM_MAX_PATH];
|
||||
|
||||
GetClientCookie(client, g_hCookie_ShowBossHitmarker, sBuffer, sizeof(sBuffer));
|
||||
@@ -243,6 +264,10 @@ public void OnClientDisconnect(int client)
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public Action OnHitmarkerSettings(int client, int args)
|
||||
{
|
||||
if(!g_hCVar_HitmarkerEnabled.BoolValue)
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
ShowSettingsMenu(client);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
@@ -252,6 +277,10 @@ public Action OnHitmarkerSettings(int client, int args)
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public Action OnToggleBossHitmarker(int client, int args)
|
||||
{
|
||||
if(!g_hCVar_HitmarkerEnabled.BoolValue)
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
ToggleBossHitmarker(client);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
@@ -275,6 +304,10 @@ public void ToggleBossHitmarker(int client)
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public Action OnToggleZombieHitmarker(int client, int args)
|
||||
{
|
||||
if(!g_hCVar_HitmarkerEnabled.BoolValue)
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
ToggleZombieHitmarker(client);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
@@ -284,6 +317,10 @@ public Action OnToggleZombieHitmarker(int client, int args)
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void ToggleZombieHitmarker(int client)
|
||||
{
|
||||
if(!g_hCVar_HitmarkerEnabled.BoolValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
g_bShowZombieHitmarker[client] = !g_bShowZombieHitmarker[client];
|
||||
SetClientCookie(client, g_hCookie_ShowZombieHitmarker, g_bShowZombieHitmarker[client] ? "1" : "");
|
||||
|
||||
@@ -298,6 +335,10 @@ public void ToggleZombieHitmarker(int client)
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public Action OnToggleHitmarkerSound(int client, int args)
|
||||
{
|
||||
if(!g_hCVar_HitmarkerEnabled.BoolValue)
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
ToggleHitmarkerSound(client);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
@@ -307,6 +348,10 @@ public Action OnToggleHitmarkerSound(int client, int args)
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void ToggleHitmarkerSound(int client)
|
||||
{
|
||||
if(!g_hCVar_HitmarkerEnabled.BoolValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
g_bHitmarkerSound[client] = !g_bHitmarkerSound[client];
|
||||
SetClientCookie(client, g_hCookie_HitmarkerSound, g_bHitmarkerSound[client] ? "1" : "");
|
||||
|
||||
@@ -321,6 +366,10 @@ public void ToggleHitmarkerSound(int client)
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void ToggleHitmarkerSoundVolume(int client)
|
||||
{
|
||||
if(!g_hCVar_HitmarkerEnabled.BoolValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
g_iHitmarkerSoundVolume[client] += 25;
|
||||
|
||||
if(g_iHitmarkerSoundVolume[client] > 100)
|
||||
@@ -339,6 +388,10 @@ public void ToggleHitmarkerSoundVolume(int client)
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void ToggleHitmarkerSkin(int client)
|
||||
{
|
||||
if(!g_hCVar_HitmarkerEnabled.BoolValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
g_iHitmarkerSkin[client]++;
|
||||
|
||||
if (StrEqual(g_sHitmarkerSkins[g_iHitmarkerSkin[client]], ""))
|
||||
@@ -354,6 +407,10 @@ public void ToggleHitmarkerSkin(int client)
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void ShowSettingsMenu(int client)
|
||||
{
|
||||
if(!g_hCVar_HitmarkerEnabled.BoolValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Menu menu = new Menu(MenuHandler_MainMenu);
|
||||
|
||||
menu.SetTitle("Hitmarker Settings", client);
|
||||
@@ -434,6 +491,10 @@ public int MenuHandler_MainMenu(Menu menu, MenuAction action, int client, int se
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnEntitySpawned(int Entity, const char[] sClassname)
|
||||
{
|
||||
if(!g_hCVar_HitmarkerEnabled.BoolValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int ent = EntRefToEntIndex(Entity);
|
||||
|
||||
if (0 < ent < MAX_EDICTS)
|
||||
@@ -451,6 +512,10 @@ public void OnEntitySpawned(int Entity, const char[] sClassname)
|
||||
/*
|
||||
public void OnBossDamaged(CBoss Boss, CConfig Config, int client, float damage)
|
||||
{
|
||||
if(!g_hCVar_HitmarkerEnabled.BoolValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!IsValidClient(client))
|
||||
return;
|
||||
|
||||
@@ -475,6 +540,10 @@ public void OnBossDamaged(CBoss Boss, CConfig Config, int client, float damage)
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public MRESReturn Detour_OnTakeDamage(int entity, Handle hReturn, Handle hParams)
|
||||
{
|
||||
if(!g_hCVar_HitmarkerEnabled.BoolValue)
|
||||
{
|
||||
return MRES_Ignored;
|
||||
}
|
||||
//https://github.com/alliedmodders/hl2sdk/blob/css/game/shared/takedamageinfo.h#L115
|
||||
int iHealth = GetEntProp(entity, Prop_Data, "m_iHealth");
|
||||
int client = DHookGetParamObjectPtrVar(hParams, 1, 3*(3*4) + 0, ObjectValueType_Ehandle);
|
||||
@@ -514,6 +583,10 @@ public MRESReturn Detour_OnTakeDamage(int entity, Handle hReturn, Handle hParams
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnClientHurt(Event hEvent, const char[] sEvent, bool bDontBroadcast)
|
||||
{
|
||||
if(!g_hCVar_HitmarkerEnabled.BoolValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int client = GetClientOfUserId(hEvent.GetInt("attacker"));
|
||||
int victim = GetClientOfUserId(hEvent.GetInt("userid"));
|
||||
|
||||
@@ -544,6 +617,10 @@ public void OnClientHurt(Event hEvent, const char[] sEvent, bool bDontBroadcast)
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
void ShowOverlay(int client, float fTime = 0.3)
|
||||
{
|
||||
if(!g_hCVar_HitmarkerEnabled.BoolValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (g_bHitmarkerSound[client])
|
||||
{
|
||||
float fVolume = g_iHitmarkerSoundVolume[client] / 100.0;
|
||||
|
||||
Reference in New Issue
Block a user