Permalink
Browse files

Add button log function (disabled by default)

Set ttt_log_pressed_buttons to 1 if you want it
  • Loading branch information...
Bara committed May 6, 2018
1 parent 1de7883 commit ff3884c9aae05c243aa6396f51c6bb1cbbac7269
@@ -128,6 +128,8 @@ void SetupConfig()
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_cLogButtons = AutoExecConfig_CreateConVar("ttt_log_pressed_buttons", "0", "Log pressed buttons?", _, true, 0.0, true, 1.0);
g_cLogButtonsSpam = AutoExecConfig_CreateConVar("ttt_log_pressed_buttons", "5", "Prevent log spamming for the same button - Time in seconds to relog a button");
g_cpluginTag.AddChangeHook(OnConVarChanged);
g_ckickImmunity.AddChangeHook(OnConVarChanged);
@@ -280,6 +280,8 @@ ConVar g_cKarmaDecreaseWhenKillPlayerWhoHurt = null;
ConVar g_cSilentIdEnabled = null;
ConVar g_cSilentIdColor = null;
ConVar g_cSilentIdRoles = null;
ConVar g_cLogButtons = null;
ConVar g_cLogButtonsSpam = null;
Handle g_hRules = null;
bool g_bRules[MAXPLAYERS + 1] = { false, ... };
@@ -289,3 +291,5 @@ bool g_bDRules[MAXPLAYERS + 1] = { false, ... };
Handle g_hRSCookie = null;
int g_iRoundSlays[MAXPLAYERS + 1] = { 0, ... };
bool g_bPressed[MAXPLAYERS + 1] = { false, ... };
@@ -186,6 +186,11 @@ public void OnConfigsExecuted()
LogMessage("Log File: \"%s\"", g_sLogFile);
LogMessage("Error File :\"%s\"", g_sErrorFile);
}
if (g_cLogButtons.BoolValue)
{
HookEntityOutput("func_button", "OnPressed", OnButtonPressed);
}
}
public void TTT_OnSQLConnect(Database db)
@@ -559,6 +564,58 @@ public Action Command_Karma(int client, int args)
return Plugin_Handled;
}
public OnButtonPressed(const String:output[], entity, client, Float:delay)
{
if (!TTT_IsClientValid(client) || !IsPlayerAlive(client))
{
return;
}
if (g_bPressed[entity])
{
return;
}
char sClientID[32], sRole[ROLE_LENGTH], sName[512], iItem[TTT_LOG_SIZE];
if (g_cAddSteamIDtoLogs.BoolValue)
{
if (g_cSteamIDLogFormat.IntValue == 1)
{
GetClientAuthId(client, AuthId_Steam2, sClientID, sizeof(sClientID));
}
else if (g_cSteamIDLogFormat.IntValue == 2)
{
GetClientAuthId(client, AuthId_Steam3, sClientID, sizeof(sClientID));
}
else if (g_cSteamIDLogFormat.IntValue == 3)
{
GetClientAuthId(client, AuthId_SteamID64, sClientID, sizeof(sClientID));
}
if (strlen(sClientID) > 2)
{
Format(sClientID, sizeof(sClientID), " (%s)", sClientID);
}
}
TTT_GetRoleNameByID(TTT_GetClientRole(client), sRole, sizeof(sRole));
GetEntPropString(entity, Prop_Data, "m_iName", sName, sizeof(sName));
Format(iItem, sizeof(iItem), "-> [%N%s (%s) pressed the button %s (%d)]", client, sClientID, sRole, sName, entity);
g_bPressed[entity] = true;
CreateTimer(g_cLogButtonsSpam.FloatValue, Timer_EnableButton, EntIndexToEntRef(entity));
}
public Action Timer_EnableButton(Handle timer, any reference)
{
int entity = EntRefToEntIndex(reference);
if (IsValidEntity(entity))
{
g_bPressed[entity] = false;
}
}
public Action Event_RoundStartPre(Event event, const char[] name, bool dontBroadcast)
{
if (g_cDebugMessages.BoolValue)

0 comments on commit ff3884c

Please sign in to comment.