Permalink
Browse files

Silent ID Feature (#322)

* Shop forward for Body Found

* Silent ID feature

* CVARs

* Variables for CVARs

* Update forward for Body Found

* Updating CVAR value and description

* Oops, sorry

* Moving Reward CVAR to Shop plugin

* Moving Reward ConVar to Shop plugin

* Changing verifications...

* Changing forward...

* Typo :x

* Didn't know it was possible to send bool values

* Typo the return Part 2. :c

* Fixed compiling issues and verification

* No reason to have this.

* Description for the forward

* Forgot to commit this :x

* Fixing a few errors and code clean

* Forgot the changes ...

* Removed the Call_PushCell by mistake...

* Reverting changes. Not necessary as discussed

* Forgot something important. ~ I knew it! xD

* Different translations for Silent ID

* We need more buttons and translations

* CVAR values were limited to 0 and 1

* Some extra things

* Translation params

* Translation params

* Removing bool variable
  • Loading branch information...
danielsartor authored and good-live committed May 5, 2018
1 parent 7638f06 commit de344f3ab1c0af1b8b1c8484b8b62a05dcbfc6b5
@@ -108,8 +108,9 @@ forward Action TTT_OnClientDeathPre(int victim, int attacker);
* @param client The client who identified the body.
* @param victim The client whom the body belongs to. (-1 for invalid index)
* @param deadPlayer The name of the victim.
* @param silentID True if body was silenced id and false if normal inspect
*/
forward void TTT_OnBodyFound(int client, int victim, const char[] deadPlayer);
forward void TTT_OnBodyFound(int client, int victim, const char[] deadPlayer, bool silentID);
/*
* Called when a body is scanned (by a Detective - not really? (Line 2761-2765 ttt.sp) -).
@@ -125,6 +125,9 @@ void SetupConfig()
g_cDoublePushInno = AutoExecConfig_CreateConVar("ttt_double_push_innocents", "1", "Push innocents (from last round) two times into players array? This should increase the chance to get traitor in the new round.", _, true, 0.0, true, 1.0);
g_cDoublePushDete = AutoExecConfig_CreateConVar("ttt_double_push_detective", "1", "Push detective (from last round) two times into players array? This should increase the chance to get traitor in the new round.", _, true, 0.0, true, 1.0);
g_cKarmaDecreaseWhenKillPlayerWhoHurt = AutoExecConfig_CreateConVar("ttt_karma_decrease_kill_player_who_hurted", "1", "Decrease Karma when you kill a player who hurted you?.", _, true, 0.0, true, 1.0);
g_cSilentIdEnabled = AutoExecConfig_CreateConVar("ttt_silent_id", "0", "0 = Disabled. 1 = Enable silent id (+speed and +use together). Silent ID wont print on chat when someone inspects a body.", _, true, 0.0, true, 1.0);
g_cSilentIdColor = AutoExecConfig_CreateConVar("ttt_silent_id_color", "1", "0 = Disabled, will not change the color of the body. 1 = Silent ID will color the body when inspecting. (Green = Innocent, Red = Traitor, Blue = Detective)", _, true, 0.0, true, 1.0);
g_cSilentIdRoles = AutoExecConfig_CreateConVar("ttt_silent_id_roles", "14", "2 = Innocent. 4 = Traitor. 8 = Detective. For other combinations, just sum the values. (i.e.: 14 (2+4+8) = All roles can Silent ID)");
g_cpluginTag.AddChangeHook(OnConVarChanged);
g_ckickImmunity.AddChangeHook(OnConVarChanged);
@@ -277,6 +277,9 @@ ConVar g_cDamageKarmaDD = null;
ConVar g_cDoublePushInno = null;
ConVar g_cDoublePushDete = null;
ConVar g_cKarmaDecreaseWhenKillPlayerWhoHurt = null;
ConVar g_cSilentIdEnabled = null;
ConVar g_cSilentIdColor = null;
ConVar g_cSilentIdRoles = null;
Handle g_hRules = null;
bool g_bRules[MAXPLAYERS + 1] = { false, ... };
@@ -7,7 +7,7 @@ void InitForwards()
g_hOnClientGetRole = CreateGlobalForward("TTT_OnClientGetRole", ET_Ignore, Param_Cell, Param_Cell);
g_hOnClientDeath = CreateGlobalForward("TTT_OnClientDeath", ET_Ignore, Param_Cell, Param_Cell);
g_hOnClientDeathPre = CreateGlobalForward("TTT_OnClientDeathPre", ET_Event, Param_Cell, Param_Cell);
g_hOnBodyFound = CreateGlobalForward("TTT_OnBodyFound", ET_Ignore, Param_Cell, Param_Cell, Param_String);
g_hOnBodyFound = CreateGlobalForward("TTT_OnBodyFound", ET_Ignore, Param_Cell, Param_Cell, Param_String, Param_Cell);
g_hOnBodyChecked = CreateGlobalForward("TTT_OnBodyChecked", ET_Event, Param_Cell, Param_Array);
g_hOnButtonPress = CreateGlobalForward("TTT_OnButtonPress", ET_Ignore, Param_Cell, Param_Cell);
g_hOnButtonRelease = CreateGlobalForward("TTT_OnButtonRelease", ET_Ignore, Param_Cell, Param_Cell);
@@ -2901,13 +2901,17 @@ public Action OnPlayerRunCmd(int client, int &buttons)
{
button = (1 << i);
if ((buttons & button))
if ((buttons & button) || (buttons & IN_USE|IN_SPEED) == IN_USE|IN_SPEED)
{
if (!(g_iLastButtons[client] & button))
{
Call_StartForward(g_hOnButtonPress);
Call_PushCell(client);
Call_PushCell(button);
if ((buttons & IN_USE|IN_SPEED) == IN_USE|IN_SPEED) {
Call_PushCell(buttons);
} else {
Call_PushCell(button);
}
Call_Finish();
}
}
@@ -2989,6 +2993,9 @@ public int TTT_OnButtonPress(int client, int button)
if (!iRagdollC[Found] && IsPlayerAlive(client))
{
bool bInWalk = ((button & IN_SPEED) > 0);
bool silentID = false;
iRagdollC[Found] = true;
bool bValid = false;
@@ -3010,35 +3017,87 @@ public int TTT_OnButtonPress(int client, int button)
if (iRagdollC[VictimTeam] == TTT_TEAM_INNOCENT)
{
LoopValidClients(j)
if (!g_cSilentIdEnabled.BoolValue || !(bInWalk && TTT_ValidSilentIDRole(client, g_cSilentIdRoles.IntValue)))
{
CPrintToChat(j, "%s %T", g_sTag, "Found Innocent", j, client, iRagdollC[VictimName]);
LoopValidClients(j)
{
CPrintToChat(j, "%s %T", g_sTag, "Found Innocent", j, client, iRagdollC[VictimName]);
}
Format(iItem, sizeof(iItem), "-> %N (%s) identified body of %s (Innocent)", client, sRole, iRagdollC[VictimName]);
SetEntityRenderColor(iEntity, 0, 255, 0, 255);
}
else
{
CPrintToChat(client, "%s %T", g_sTag, "Found Innocent Silent", client, iRagdollC[VictimName]);
Format(iItem, sizeof(iItem), "-> %N (%s) identified body of %s (Innocent) - SILENT", client, sRole, iRagdollC[VictimName]);
if (g_cSilentIdColor.BoolValue)
{
SetEntityRenderColor(iEntity, 0, 255, 0, 255);
}
silentID = true;
}
SetEntityRenderColor(iEntity, 0, 255, 0, 255);
Format(iItem, sizeof(iItem), "-> %N (%s) identified body of %s (Innocent)", client, sRole, iRagdollC[VictimName]);
addArrayTime(iItem);
}
else if (iRagdollC[VictimTeam] == TTT_TEAM_DETECTIVE)
{
LoopValidClients(j)
if (!g_cSilentIdEnabled.BoolValue || !(bInWalk && TTT_ValidSilentIDRole(client, g_cSilentIdRoles.IntValue)))
{
CPrintToChat(j, "%s %T", g_sTag, "Found Detective", j, client, iRagdollC[VictimName]);
LoopValidClients(j)
{
CPrintToChat(j, "%s %T", g_sTag, "Found Detective", j, client, iRagdollC[VictimName]);
}
Format(iItem, sizeof(iItem), "-> %N (%s) identified body of %s (Detective)", client, sRole, iRagdollC[VictimName]);
SetEntityRenderColor(iEntity, 0, 0, 255, 255);
}
SetEntityRenderColor(iEntity, 0, 0, 255, 255);
Format(iItem, sizeof(iItem), "-> %N (%s) identified body of %s (Detective)", client, sRole, iRagdollC[VictimName]);
else
{
CPrintToChat(client, "%s %T", g_sTag, "Found Detective Silent", client, iRagdollC[VictimName]);
Format(iItem, sizeof(iItem), "-> %N (%s) identified body of %s (Detective) - SILENT", client, sRole, iRagdollC[VictimName]);
if (g_cSilentIdColor.BoolValue)
{
SetEntityRenderColor(iEntity, 0, 0, 255, 255);
}
silentID = true;
}
addArrayTime(iItem);
}
else if (iRagdollC[VictimTeam] == TTT_TEAM_TRAITOR)
{
LoopValidClients(j)
if (!g_cSilentIdEnabled.BoolValue || !(bInWalk && TTT_ValidSilentIDRole(client, g_cSilentIdRoles.IntValue)))
{
CPrintToChat(j, "%s %T", g_sTag, "Found Traitor", j, client, iRagdollC[VictimName]);
LoopValidClients(j)
{
CPrintToChat(j, "%s %T", g_sTag, "Found Traitor", j, client, iRagdollC[VictimName]);
}
Format(iItem, sizeof(iItem), "-> %N (%s) identified body of %s (Traitor)", client, sRole, iRagdollC[VictimName]);
SetEntityRenderColor(iEntity, 255, 0, 0, 255);
}
else
{
CPrintToChat(client, "%s %T", g_sTag, "Found Traitor Silent", client, iRagdollC[VictimName]);
Format(iItem, sizeof(iItem), "-> %N (%s) identified body of %s (Traitor) - SILENT", client, sRole, iRagdollC[VictimName]);
if (g_cSilentIdColor.BoolValue)
{
SetEntityRenderColor(iEntity, 255, 0, 0, 255);
}
silentID = true;
}
SetEntityRenderColor(iEntity, 255, 0, 0, 255);
Format(iItem, sizeof(iItem), "-> %N (%s) identified body of %s (Traitor)", client, sRole, iRagdollC[VictimName]);
addArrayTime(iItem);
}
@@ -3060,6 +3119,7 @@ public int TTT_OnButtonPress(int client, int button)
}
Call_PushString(iRagdollC[VictimName]);
Call_PushCell(silentID);
Call_Finish();
}
g_aRagdoll.SetArray(i, iRagdollC[0]);
@@ -3071,6 +3131,10 @@ public int TTT_OnButtonPress(int client, int button)
}
}
public TTT_ValidSilentIDRole(int client, int role) {
return (role & TTT_GetClientRole(client));
}
public int TTT_OnButtonRelease(int client, int button)
{
if (button & IN_USE)
@@ -56,6 +56,7 @@ ConVar g_cCreditsMin = null;
ConVar g_cCreditsMax = null;
ConVar g_cCreditsInterval = null;
ConVar g_cSQLCredits = null;
ConVar g_cSilentIdRewards = null;
ConVar g_cPluginTag = null;
char g_sPluginTag[64];
@@ -176,6 +177,7 @@ public void OnPluginStart()
g_cBuyCmd = AutoExecConfig_CreateConVar("ttt_shop_buy_command", "buyitem", "The command to buy a shop item instantly");
g_cShowCmd = AutoExecConfig_CreateConVar("ttt_shop_show_command", "showitems", "The command to show the shortname of the shopitems (to use for the buycommand)");
g_cSQLCredits = AutoExecConfig_CreateConVar("ttt_sql_credits", "0", "Set 1 if you want to use credits over sql (mysql + sqlite are supported)", _, true, 0.0, true, 1.0);
g_cSilentIdRewards = AutoExecConfig_CreateConVar("ttt_shop_silent_id_rewards", "1", "0 = Disabled, will not reward credits with silent id. 1 = Will reward the client with credits for inspecting the body.", _, true, 0.0, true, 1.0);
TTT_EndConfig();
LoadTranslations("common.phrases");
@@ -1063,9 +1065,12 @@ public void TTT_OnRoundEnd(int WinningTeam)
}
}
public void TTT_OnBodyFound(int client, int victim, const char[] deadPlayer)
public void TTT_OnBodyFound(int client, int victim, const char[] deadPlayer, bool silentID)
{
addCredits(client, g_cCreditsFoundBody.IntValue);
if (!silentID || (g_cSilentIdRewards.BoolValue && silentID))
{
addCredits(client, g_cCreditsFoundBody.IntValue);
}
}
stock void addCredits(int client, int credits, bool message = false)
@@ -1004,5 +1004,21 @@
"#format" "{1:s}"
"en" "Can't find '{1}' as valid shop item"
}
"Found Innocent Silent"
{
"#format" "{1:s}"
"en" "{lightgreen}You silently found the body of {green}{1}. {lightgreen}It was a {green}INNOCENT!"
}
"Found Detective Silent"
{
"#format" "{1:s}"
"en" "{lightgreen}You silently found the body of {darkblue}{1}. {lightgreen}It was a {darkblue}DETECTIVE!"
}
"Found Traitor Silent"
{
"#format" "{1:s}"
"en" "{lightgreen}You silently found the body of {darkred}{1}. {lightgreen}It was a {darkred}Traitor!"
}
}

0 comments on commit de344f3

Please sign in to comment.