Permalink
Browse files

Add option to hide role colors for wallhack

Close #160
  • Loading branch information...
Bara committed Nov 28, 2017
1 parent f9785cd commit a62b3921a4dfa04ae3811f1e8091df8d16329b3e
@@ -3,7 +3,7 @@
#endif
#define _ttt_glow_included
forward Action TTT_OnGlowCheck(int client, int target, bool &seeTarget);
forward Action TTT_OnGlowCheck(int client, int target, bool &seeTarget, bool &overrideColor, int &red, int &green, int &blue, int &alpha);
public SharedPlugin __pl_ttt_glow =
{
@@ -31,7 +31,7 @@ public Plugin myinfo =
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
{
g_hOnGlowCheck = CreateGlobalForward("TTT_OnGlowCheck", ET_Event, Param_Cell, Param_Cell, Param_CellByRef);
g_hOnGlowCheck = CreateGlobalForward("TTT_OnGlowCheck", ET_Event, Param_Cell, Param_Cell, Param_CellByRef, Param_CellByRef, Param_CellByRef, Param_CellByRef, Param_CellByRef, Param_CellByRef);
RegPluginLibrary("ttt_glow");
@@ -265,15 +265,45 @@ public Action OnSetTransmit_GlowSkin(int skin, int client)
return Plugin_Continue;
}
bool result = false;
bool seeTarget = false;
bool override = false;
int red = 255;
int green = 255;
int blue = 255;
int alpha = 255;
Call_StartForward(g_hOnGlowCheck);
Call_PushCell(client);
Call_PushCell(target);
Call_PushCellRef(result);
Call_PushCellRef(seeTarget);
Call_PushCellRef(override);
Call_PushCellRef(red);
Call_PushCellRef(green);
Call_PushCellRef(blue);
Call_PushCellRef(alpha);
Call_Finish();
if (!result)
if (seeTarget && override)
{
int iSkin = EntRefToEntIndex(CPS_GetSkin(target));
if(IsValidEntity(iSkin))
{
int iOffset;
if ((iOffset = GetEntSendPropOffs(iSkin, "m_clrGlow")) == -1)
{
return Plugin_Handled;
}
SetEntData(iSkin, iOffset, red, _, true);
SetEntData(iSkin, iOffset + 1, green, _, true);
SetEntData(iSkin, iOffset + 2, blue, _, true);
SetEntData(iSkin, iOffset + 3, alpha, _, true);
}
}
if (!seeTarget)
{
return Plugin_Handled;
}
@@ -29,6 +29,12 @@ ConVar g_cDetectiveActive = null;
ConVar g_cLongName = null;
ConVar g_cDiscountT = null;
ConVar g_cDiscountD = null;
ConVar g_cColorsT = null;
ConVar g_cColorsD = null;
ConVar g_cDefaultRed = null;
ConVar g_cDefaultGreen = null;
ConVar g_cDefaultBlue = null;
ConVar g_cDefaultAlpha = null;
bool g_bOwnWH[MAXPLAYERS + 1] = { false, ... };
bool g_bHasWH[MAXPLAYERS + 1] = { false, ... };
@@ -64,6 +70,12 @@ public void OnPluginStart()
g_cDetective_Prio = AutoExecConfig_CreateConVar("wh_detective_sort_prio", "0", "The sorting priority of the Detective - Wallhack in the shop menu.");
g_cDiscountT = AutoExecConfig_CreateConVar("wh_discount_traitor", "0", "Should wallhack discountable for traitors?", _, true, 0.0, true, 1.0);
g_cDiscountD = AutoExecConfig_CreateConVar("wh_discount_detective", "0", "Should wallhack discountable for detectives?", _, true, 0.0, true, 1.0);
g_cColorsT = AutoExecConfig_CreateConVar("wh_show_roles_traitor", "1", "Show glows as role colors for traitors?", _, true, 0.0, true, 1.0);
g_cColorsD = AutoExecConfig_CreateConVar("wh_show_roles_detective", "0", "Show glows as role colors for detectives?", _, true, 0.0, true, 1.0);
g_cDefaultRed = AutoExecConfig_CreateConVar("wh_default_color_red", "255", "Red color of default glow");
g_cDefaultGreen = AutoExecConfig_CreateConVar("wh_default_color_green", "255", "Green color of default glow");
g_cDefaultBlue = AutoExecConfig_CreateConVar("wh_default_color_blue", "255", "Blue color of default glow");
g_cDefaultAlpha = AutoExecConfig_CreateConVar("wh_default_color_alpha", "255", "Alpha of default glow");
EndConfig();
HookEvent("player_spawn", Event_PlayerReset);
@@ -215,10 +227,47 @@ public Action Timer_WHCooldown(Handle timer, any userid)
return Plugin_Stop;
}
public Action TTT_OnGlowCheck(int client, int target, bool &seeTarget)
public Action TTT_OnGlowCheck(int client, int target, bool &seeTarget, bool &overrideColor, int &red, int &green, int &blue, int &alpha)
{
if (g_bHasWH[client] && g_bOwnWH[client])
{
int role = TTT_GetClientRole(client);
if (role == TTT_TEAM_TRAITOR)
{
if (g_cColorsT.BoolValue)
{
seeTarget = true;
return Plugin_Changed;
}
else
{
seeTarget = true;
overrideColor = true;
red = g_cDefaultRed.IntValue;
green = g_cDefaultGreen.IntValue;
blue = g_cDefaultBlue.IntValue;
alpha = g_cDefaultAlpha.IntValue;
}
}
else if (role == TTT_TEAM_DETECTIVE)
{
if (g_cColorsD.BoolValue)
{
seeTarget = true;
return Plugin_Changed;
}
else
{
seeTarget = true;
overrideColor = true;
red = g_cDefaultRed.IntValue;
green = g_cDefaultGreen.IntValue;
blue = g_cDefaultBlue.IntValue;
alpha = g_cDefaultAlpha.IntValue;
}
}
seeTarget = true;
return Plugin_Changed;
}

0 comments on commit a62b392

Please sign in to comment.