NoAdminTools: improve sm_checkadmins
This commit is contained in:
parent
eeba405984
commit
5f01907035
@ -15,6 +15,7 @@ float g_fSelfExtendsDelay;
|
|||||||
|
|
||||||
bool g_bSelfExtends[MAXPLAYERS + 1] = { false, ...};
|
bool g_bSelfExtends[MAXPLAYERS + 1] = { false, ...};
|
||||||
bool g_bSelfExtendsAllowed;
|
bool g_bSelfExtendsAllowed;
|
||||||
|
bool g_bActiveAdmin[MAXPLAYERS + 1] = { false, ...};
|
||||||
int g_iSelfExtends;
|
int g_iSelfExtends;
|
||||||
|
|
||||||
ConVar g_cvarTimeLimit;
|
ConVar g_cvarTimeLimit;
|
||||||
@ -24,7 +25,7 @@ public Plugin myinfo =
|
|||||||
name = "No Admin Tools",
|
name = "No Admin Tools",
|
||||||
author = "Dogan",
|
author = "Dogan",
|
||||||
description = "Make it possible for the server to do several things when there is no active admin online",
|
description = "Make it possible for the server to do several things when there is no active admin online",
|
||||||
version = "1.0.0",
|
version = "1.1.0",
|
||||||
url = ""
|
url = ""
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -76,24 +77,29 @@ public void Cvar_SelfExtendsDelay(ConVar convar, const char[] oldValue, const ch
|
|||||||
g_fSelfExtendsDelay = convar.FloatValue;
|
g_fSelfExtendsDelay = convar.FloatValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ActiveAdminPresent()
|
public bool ActiveAdmin(int client)
|
||||||
{
|
{
|
||||||
for(int i = 1; i <= MaxClients; i++)
|
if(GetClientIdleTime(client) < g_iAdminAFKTime)
|
||||||
{
|
return true;
|
||||||
if(IsValidClient(i) && CheckCommandAccess(i, "", ADMFLAG_GENERIC) && (GetClientIdleTime(i) < g_iAdminAFKTime))
|
|
||||||
return true;
|
return false;
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnClientDisconnect(int client)
|
public void OnClientDisconnect(int client)
|
||||||
{
|
{
|
||||||
g_bSelfExtends[client] = false;
|
g_bSelfExtends[client] = false;
|
||||||
|
g_bActiveAdmin[client] = false;
|
||||||
|
|
||||||
CheckRatio();
|
CheckRatio();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnClientPutInServer(int client)
|
public void OnClientPostAdminCheck(int client)
|
||||||
{
|
{
|
||||||
|
if(CheckCommandAccess(client, "", ADMFLAG_GENERIC) && IsValidClient(client))
|
||||||
|
{
|
||||||
|
g_bActiveAdmin[client] = true;
|
||||||
|
}
|
||||||
|
|
||||||
CheckRatio();
|
CheckRatio();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,22 +126,67 @@ public Action Timer_DelaySelfExtend(Handle timer)
|
|||||||
|
|
||||||
public Action Command_DisplayActiveAdmins(int client, int args)
|
public Action Command_DisplayActiveAdmins(int client, int args)
|
||||||
{
|
{
|
||||||
if(ActiveAdminPresent())
|
for(int i = 1; i <= MaxClients; i++)
|
||||||
ReplyToCommand(client, "[SM] There are active Admins online.");
|
if(CheckCommandAccess(i, "", ADMFLAG_GENERIC) && IsValidClient(i) && ActiveAdmin(i))
|
||||||
|
g_bActiveAdmin[i] = true;
|
||||||
|
|
||||||
|
char aBuf[1024];
|
||||||
|
char aBuf2[MAX_NAME_LENGTH];
|
||||||
|
char bBuf[1024];
|
||||||
|
char bBuf2[MAX_NAME_LENGTH];
|
||||||
|
|
||||||
|
for(int i = 1; i <= MaxClients; i++)
|
||||||
|
{
|
||||||
|
if(IsClientInGame(i) && !IsFakeClient(i))
|
||||||
|
{
|
||||||
|
if(g_bActiveAdmin[i])
|
||||||
|
{
|
||||||
|
GetClientName(i, aBuf2, sizeof(aBuf2));
|
||||||
|
StrCat(aBuf, sizeof(aBuf), aBuf2);
|
||||||
|
StrCat(aBuf, sizeof(aBuf), ", ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!g_bActiveAdmin[i] && CheckCommandAccess(i, "", ADMFLAG_GENERIC) && IsValidClient(i))
|
||||||
|
{
|
||||||
|
GetClientName(i, bBuf2, sizeof(bBuf2));
|
||||||
|
StrCat(bBuf, sizeof(bBuf), bBuf2);
|
||||||
|
StrCat(bBuf, sizeof(bBuf), ", ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(strlen(aBuf))
|
||||||
|
{
|
||||||
|
aBuf[strlen(aBuf) - 2] = 0;
|
||||||
|
ReplyToCommand(client, "[SM] Active Admins online: %s", aBuf);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
ReplyToCommand(client, "[SM] There are no active Admins online.");
|
ReplyToCommand(client, "[SM] Active Admins online: none");
|
||||||
|
|
||||||
|
if(strlen(bBuf))
|
||||||
|
{
|
||||||
|
bBuf[strlen(bBuf) - 2] = 0;
|
||||||
|
ReplyToCommand(client, "[SM] Inactive Admins online: %s", bBuf);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ReplyToCommand(client, "[SM] Inactive Admins online: none");
|
||||||
|
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Action Command_SelfExtend(int client, int args)
|
public Action Command_SelfExtend(int client, int args)
|
||||||
{
|
{
|
||||||
|
int iAdminActivity = 0;
|
||||||
|
for(int i = 1; i <= MaxClients; i++)
|
||||||
|
if(g_bActiveAdmin[i])
|
||||||
|
iAdminActivity++;
|
||||||
|
|
||||||
if(GetExtendsLeft() > 0)
|
if(GetExtendsLeft() > 0)
|
||||||
{
|
{
|
||||||
ReplyToCommand(client, "[SM] Not available because not all regular extends have been depleted.");
|
ReplyToCommand(client, "[SM] Not available because not all regular extends have been depleted.");
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
if(ActiveAdminPresent())
|
if(iAdminActivity > 0)
|
||||||
{
|
{
|
||||||
ReplyToCommand(client, "[SM] Not available because there is atleast one active Admin who can extend. Please ask the Admins.");
|
ReplyToCommand(client, "[SM] Not available because there is atleast one active Admin who can extend. Please ask the Admins.");
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
|
Loading…
Reference in New Issue
Block a user