Send message if vote kicked admin was afk, some debug info

This commit is contained in:
Jackz 2022-07-21 22:53:52 -05:00
parent 90a142dbd4
commit d3035be21d
No known key found for this signature in database
GPG key ID: E0BBD94CF657F603
2 changed files with 23 additions and 16 deletions

Binary file not shown.

View file

@ -1,7 +1,8 @@
#pragma semicolon 1
#pragma newdecls required
#define PLUGIN_VERSION "1.0"
#define ANTI_ADMIN_KICK_MIN_TIME 120 // The number of seconds after joining where vote kicking an admin, kicks the caller
#define PLUGIN_VERSION "1.1"
#include <sourcemod>
#include <sdktools>
@ -10,8 +11,6 @@
static int disableFFClient, ffDamageCount; //client to disable FF for
static ConVar forceKickFFThreshold;
static int voteController;
public Plugin myinfo = {
name = "L4D2 FF Kick Protection",
author = "jackzmc",
@ -33,9 +32,6 @@ public void OnPluginStart() {
forceKickFFThreshold = CreateConVar("sm_votekick_force_threshold","30.0","The threshold of amount of FF to then automatically kick.\n0: Any attempted damage\n -1: No auto kick.\n>0: When FF count > this", FCVAR_NONE, true, -1.0);
}
public void OnMapStart() {
voteController = FindEntityByClassname(-1, "vote_controller");
}
int iJoinTime[MAXPLAYERS+1];
public void OnClientPutInServer(int client) {
@ -65,12 +61,12 @@ public Action VoteStart(int client, const char[] command, int argc) {
}
if(GetClientCount(true) == 0 || client == 0 || client >= MaxClients) return Plugin_Handled; //prevent votes while server is empty or if server tries calling vote
if(argc >= 1) {
static char issue[32];
char issue[32];
GetCmdArg(1, issue, sizeof(issue));
if(StrEqual(issue, "Kick", false)) {
static char option[32];
char option[32];
GetCmdArg(2, option, sizeof(option));
if(strlen(option) > 1) { //empty userid/console can't call votes
@ -79,22 +75,33 @@ public Action VoteStart(int client, const char[] command, int argc) {
if(client <= 0 || client >= MaxClients || !IsClientConnected(client)) return Plugin_Continue; //invalid, pass it through
AdminId callerAdmin = GetUserAdmin(client);
AdminId targetAdmin = GetUserAdmin(target);
if(targetAdmin != INVALID_ADMIN_ID) { //Only run if vote is against an admin
//Only run if vote is against an admin
if(targetAdmin != INVALID_ADMIN_ID) {
for(int i = 1; i <= MaxClients; i++) {
if(target != i && IsClientConnected(i) && IsClientInGame(i) && GetUserAdmin(i) != INVALID_ADMIN_ID) {
PrintToChat(i, "%N attempted to vote-kick %N", client, target);
PrintToChat(i, "%N attempted to vote-kick admin %N", client, target);
}
}
if(callerAdmin == INVALID_ADMIN_ID && GetTime() - iJoinTime[client] <= 120) {
KickClient(client, "No.");
PrintToChat(target, "%N has attempted to vote kick you and was kicked.", client);
// Kick player if they are not an admin and just recently joined.
// Else, just tell the target
if(callerAdmin == INVALID_ADMIN_ID && GetTime() - iJoinTime[client] <= ANTI_ADMIN_KICK_MIN_TIME) {
if(GetClientTeam(target) >= 2) {
KickClient(client, "No.");
PrintToChat(target, "%N has attempted to vote kick you and was kicked.", client);
} else {
PrintToChat(client, "%N is an admin and cannot be vote kicked", target);
PrintToChat(target, "%N has attempted to kick you while you were afk.", client);
}
} else {
PrintToChat(target, "%N has attempted to vote kick you.", client);
}
// TODO: remove debug
targetAdmin.GetUsername(option, sizeof(option));
PrintToServer("debug: admin immunity is %d. username: %s", targetAdmin.ImmunityLevel, option);
PrintToServer("ADMIN VOTE KICK BLOCKED | Target=%N | Caller=%N", target, client);
return Plugin_Handled;
} else if(callerAdmin != INVALID_ADMIN_ID && targetAdmin == INVALID_ADMIN_ID && IsValidEntity(voteController)) {
} else if(callerAdmin != INVALID_ADMIN_ID && targetAdmin == INVALID_ADMIN_ID) {
PrintToServer("Vote kick by admin, instantly passing");
SetEntProp(voteController, Prop_Send, "m_votesYes", 32);
for(int i = 1; i <= MaxClients; i++) {
if(IsClientConnected(i) && !IsFakeClient(i) && GetClientTeam(i) == GetClientTeam(target)) {
ClientCommand(i, "vote Yes");
@ -105,7 +112,7 @@ public Action VoteStart(int client, const char[] command, int argc) {
disableFFClient = target;
ffDamageCount = 0;
}
PrintToServer("VOTE KICK STARTED | Target=%N | Caller=%N", issue, target, client);
PrintToServer("VOTE KICK STARTED | Target=%N | Caller=%N", target, client);
return Plugin_Continue;
}
}