sm-plugins/CallAdmin/scripting/CallAdminRestrictions.sp

68 lines
2.3 KiB
SourcePawn

#include <sourcemod>
#include <calladmin>
#include <basecomm>
#include <AFKManager>
#include <multicolors>
#pragma semicolon 1
#pragma newdecls required
int g_iAdminAFKTime;
ConVar g_cvAdminAFKTime;
public Plugin myinfo =
{
name = "CallAdmin Restrictions",
author = "Neon + Dogan",
description = "",
version = "2.0",
url = "https://steamcommunity.com/id/n3ontm"
};
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
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);
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnAdminAFKTimeChanged(ConVar convar, const char[] oldValue, const char[] newValue)
{
g_iAdminAFKTime = g_cvAdminAFKTime.IntValue;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public Action CallAdmin_OnDrawTarget(int client, int target)
{
if (CheckCommandAccess(target, "", ADMFLAG_GENERIC, true))
return Plugin_Handled;
else
return Plugin_Continue;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public Action CallAdmin_OnReportPre(int client, int target, const char[] reason)
{
int iLastReportID = CallAdmin_GetReportID();
for (int i = 1; i <= MaxClients; i++)
{
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);
}
return Plugin_Continue;
}