CallAdmin + Discord: adjust prints to discord

This commit is contained in:
Dogan 2019-10-22 19:19:21 +02:00
parent ed4a5595d2
commit 62b238dc86
2 changed files with 36 additions and 13 deletions

View File

@ -56,22 +56,13 @@ public Action CallAdmin_OnDrawTarget(int client, int target)
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public Action CallAdmin_OnReportPre(int client, int target, const char[] reason) public Action CallAdmin_OnReportPre(int client, int target, const char[] reason)
{ {
bool ActiveAdmins = false; int iLastReportID = CallAdmin_GetReportID();
for (int i = 1; i <= MaxClients; i++) for (int i = 1; i <= MaxClients; i++)
{ {
if (IsClientInGame(i) && (CheckCommandAccess(i, "", ADMFLAG_GENERIC, true)) && GetClientIdleTime(i) < g_iAdminAFKTime) if (IsClientInGame(i) && (CheckCommandAccess(i, "", ADMFLAG_GENERIC, true)) && GetClientIdleTime(i) < g_iAdminAFKTime)
{ CPrintToChat(i, "{green}[CALLADMIN] {lightgreen}%N reported %N for %s. Type {red}/calladmin_handle %d{lightgreen} in chat to handle this report.", client, target, reason, iLastReportID + 1);
ActiveAdmins = true;
CPrintToChat(i, "{green}[CALLADMIN] {lightgreen}%N reported %N for %s.", client, target, reason);
}
} }
if(ActiveAdmins) return Plugin_Continue;
{
CPrintToChat(client, "{green}[CALLADMIN] {lightgreen}Reported %N for %s.", target, reason);
return Plugin_Handled;
}
else
return Plugin_Continue;
} }

View File

@ -7,6 +7,7 @@
#include <smjansson> #include <smjansson>
#include <multicolors> #include <multicolors>
#include <sdktools> #include <sdktools>
#include <AFKManager>
#include <SteamAPI.secret> #include <SteamAPI.secret>
#include <Discord.secret> #include <Discord.secret>
@ -39,6 +40,9 @@ int g_iRatelimitReset;
int g_iLastReportID; int g_iLastReportID;
int g_iAdminAFKTime;
ConVar g_cvAdminAFKTime;
public Plugin myinfo = public Plugin myinfo =
{ {
name = "Discord core", name = "Discord core",
@ -110,6 +114,21 @@ public void OnPluginEnd()
UnhookUserMessage(g_umSayText2, Hook_UserMessage, false); UnhookUserMessage(g_umSayText2, Hook_UserMessage, false);
} }
public void OnAllPluginsLoaded()
{
if((g_cvAdminAFKTime = FindConVar("sm_admin_afk_time")) == INVALID_HANDLE)
SetFailState("Failed to find sm_admin_afk_time cvar.");
else
g_iAdminAFKTime = g_cvAdminAFKTime.IntValue;
HookConVarChange(g_cvAdminAFKTime, OnAdminAFKTimeChanged);
}
public void OnAdminAFKTimeChanged(ConVar convar, const char[] oldValue, const char[] newValue)
{
g_iAdminAFKTime = g_cvAdminAFKTime.IntValue;
}
public void OnClientAuthorized(int client, const char[] sAuthID32) public void OnClientAuthorized(int client, const char[] sAuthID32)
{ {
if (IsFakeClient(client)) if (IsFakeClient(client))
@ -676,8 +695,21 @@ public void CallAdmin_OnReportPost(int client, int target, const char[] reason)
char currentMap[64]; char currentMap[64];
GetCurrentMap(currentMap, sizeof(currentMap)); GetCurrentMap(currentMap, sizeof(currentMap));
bool ActiveAdmins = false;
for (int i = 1; i <= MaxClients; i++)
{
if (IsClientInGame(i) && (CheckCommandAccess(i, "", ADMFLAG_GENERIC, true)) && GetClientIdleTime(i) < g_iAdminAFKTime)
{
ActiveAdmins = true;
break;
}
}
char sMessage[4096]; char sMessage[4096];
Format(sMessage, sizeof(sMessage), "@here\n```%s - Tick: %d``````New report on server: %s (%s:%d)\nReportID: %d\nReporter: %s (%s)\nTarget: %s (%s)\nReason: %s\nJoin Server: steam://connect/%s:%d\nwhen in game, type !calladmin_handle %d or /calladmin_handle %d in chat to handle this report```", currentMap, GetGameTickCount(), sServerName, sServerIP, serverPort, g_iLastReportID, sClientName, sClientID, sTargetName, sTargetID, reason, sServerIP, serverPort, g_iLastReportID, g_iLastReportID); if(ActiveAdmins)
Format(sMessage, sizeof(sMessage), "```***ACTIVE ADMINS IN-GAME***``````\n%s - Tick: %d``````New report on server: %s (%s:%d)\nReportID: %d\nReporter: %s (%s)\nTarget: %s (%s)\nReason: %s\nJoin Server: steam://connect/%s:%d\nwhen in game, type !calladmin_handle %d or /calladmin_handle %d in chat to handle this report```", currentMap, GetGameTickCount(), sServerName, sServerIP, serverPort, g_iLastReportID, sClientName, sClientID, sTargetName, sTargetID, reason, sServerIP, serverPort, g_iLastReportID, g_iLastReportID);
else
Format(sMessage, sizeof(sMessage), "@here ```***NO ACTIVE ADMINS IN-GAME***``````\n%s - Tick: %d``````New report on server: %s (%s:%d)\nReportID: %d\nReporter: %s (%s)\nTarget: %s (%s)\nReason: %s\nJoin Server: steam://connect/%s:%d\nwhen in game, type !calladmin_handle %d or /calladmin_handle %d in chat to handle this report```", currentMap, GetGameTickCount(), sServerName, sServerIP, serverPort, g_iLastReportID, sClientName, sClientID, sTargetName, sTargetID, reason, sServerIP, serverPort, g_iLastReportID, g_iLastReportID);
char sUsername[MAX_NAME_LENGTH]; char sUsername[MAX_NAME_LENGTH];
GetClientName(client, sUsername, sizeof(sUsername)); GetClientName(client, sUsername, sizeof(sUsername));