Add name spam block plugin

This commit is contained in:
Jackz 2022-07-11 23:04:26 -05:00
parent b9132f9246
commit 10a6a750e3
No known key found for this signature in database
GPG key ID: E0BBD94CF657F603
4 changed files with 119 additions and 0 deletions

2
.gitignore vendored
View file

@ -7,6 +7,8 @@ scripting_ext/
!scripting/include/guessswho/* !scripting/include/guessswho/*
!scripting/hideandseek.sp !scripting/hideandseek.sp
!scripting/guessswho.sp !scripting/guessswho.sp
!scripting/sm_namespamblock.sp
!plugins/sm_namespamblock.smx
.push.settings.jsonc* .push.settings.jsonc*
template.config.js template.config.js
scripting/sm_give.sp scripting/sm_give.sp

View file

@ -37,6 +37,7 @@ Useful things:
* [l4d2_vocalize_control](#l4d2_vocalize_control) - Allows you to locally mute someone from vocalizing * [l4d2_vocalize_control](#l4d2_vocalize_control) - Allows you to locally mute someone from vocalizing
* [l4d2_hideandseek](#l4d2_hideandseek) - An enhancement to the base hide and seek mutation * [l4d2_hideandseek](#l4d2_hideandseek) - An enhancement to the base hide and seek mutation
* [l4d2_guesswho](#l4d2_guesswho) - Garrys mod's guess who in l4d2, inspired by hide and seek * [l4d2_guesswho](#l4d2_guesswho) - Garrys mod's guess who in l4d2, inspired by hide and seek
* [sm_namespamblock](#sm_namespamblock) - Basic plugin that bans players if they change their name in rapid succession
### Modified Others ### Modified Others
* [200IQBots_FlyYouFools](#200iqbots_flyyoufools) - Improved code to make it support multiple tanks and work better * [200IQBots_FlyYouFools](#200iqbots_flyyoufools) - Improved code to make it support multiple tanks and work better
@ -335,3 +336,12 @@ Vscript required for hud & mutation
Gamemode: https://steamcommunity.com/sharedfiles/filedetails/?id=2823719841 Gamemode: https://steamcommunity.com/sharedfiles/filedetails/?id=2823719841
Requires l4dtoolz and left4dhooks, and optioanlly skip intro cutscene Requires l4dtoolz and left4dhooks, and optioanlly skip intro cutscene
### sm_namespamblock
If a user changes their name 3 times within 10 seconds, they will be temp banned for 10 minutes.
Requires recompile to change.
* **Commands:**
* `status2` - Shitty name, but shows all non-admin players, sorted by last joined ascending (up top). Shows steamid and the first name they joined the server as
* `sm_status2` - Same command, but allows /status2 in chat

Binary file not shown.

View file

@ -0,0 +1,107 @@
#pragma semicolon 1
#pragma newdecls required
//#define DEBUG
#define PLUGIN_VERSION "1.0"
#include <sourcemod>
#include <sdktools>
//#include <sdkhooks>
#define MIN_TIME_BETWEEN_NAME_CHANGES 10000
#define MAX_NAME_COUNT 3
public Plugin myinfo =
{
name = "Name change Block",
author = "jackzmc",
description = "",
version = PLUGIN_VERSION,
url = "https://github.com/Jackzmc/sourcemod-plugins"
};
public void OnPluginStart() {
HookEvent("player_info", Event_PlayerInfo);
RegAdminCmd("status2", Cmd_Status2, ADMFLAG_GENERIC);
RegAdminCmd("sm_status2", Cmd_Status2, ADMFLAG_GENERIC);
}
char firstName[64][MAXPLAYERS+1];
int joinTime[MAXPLAYERS+1];
public Action Cmd_Status2(int client, int args) {
ArrayList players = new ArrayList();
for(int i = 1; i <= MaxClients; i++) {
if(IsClientConnected(i) && !IsFakeClient(i) && GetUserAdmin(i) == INVALID_ADMIN_ID) {
players.Push(i);
}
}
players.SortCustom(Sort_Players);
char buffer[64], steamid[32];
ReplyToCommand(client, "Index\tUserid\tName\tSteamID");
for(int i = 0; i < players.Length; i++) {
int player = players.Get(i);
GetClientAuthId(player, AuthId_Steam2, buffer, sizeof(buffer));
GetClientName(player, buffer, sizeof(buffer));
if(StrEqual(buffer, firstName[player]))
ReplyToCommand(client, "%d.\t#%d\t%s\t%s", player, GetClientUserId(player), buffer, steamid);
else
ReplyToCommand(client, "%d.\t#%d\t%s\t%s (formely %s)", player, GetClientUserId(player), buffer, steamid, firstName[player]);
}
ReplySource src = GetCmdReplySource();
if(src == SM_REPLY_TO_CONSOLE)
ReplyToCommand(client, "You can ban players by using their userid or steamid with #. \"sm_ban #52 0\" or \"sm_ban #STEAM_1:1:5325325 0\"");
else
ReplyToCommand(client, "You can ban players by using their userid or steamid with #. \"/ban #52 0\" or \"/ban #STEAM_1:1:5325325 0\"");
return Plugin_Handled;
}
public int Sort_Players(int index1, int index2, ArrayList array, Handle hndl) {
return joinTime[index2] - joinTime[index1];
}
static int lastNameChange[MAXPLAYERS+1];
static int nameChangeCount[MAXPLAYERS+1];
public void Event_PlayerInfo(Event event, const char[] name, bool dontBroadcast) {
int client = GetClientOfUserId(event.GetInt("userid"));
if(client && !IsFakeClient(client) && GetUserAdmin(client) == INVALID_ADMIN_ID) {
++nameChangeCount[client];
int time = GetTime();
int diff = time - lastNameChange[client];
if(diff < MIN_TIME_BETWEEN_NAME_CHANGES && nameChangeCount[client] > MAX_NAME_COUNT) {
char buffer[64];
Format(buffer, sizeof(buffer), "Excessive name changing (%d in %d seconds)", nameChangeCount[client], diff);
BanClient(client, 20, BANFLAG_AUTO, "Excessive name changing", buffer);
GetClientAuthId(client, AuthId_Steam2, buffer, sizeof(buffer));
PrintChatToAdmins("%N (steamid %s) hit excessive name change and has been banned temporarily", client, buffer);
}
lastNameChange[client] = time;
}
}
stock void PrintChatToAdmins(const char[] format, any ...) {
char buffer[254];
VFormat(buffer, sizeof(buffer), format, 2);
for(int i = 1; i < MaxClients; i++) {
if(IsClientConnected(i) && IsClientInGame(i)) {
AdminId admin = GetUserAdmin(i);
if(admin != INVALID_ADMIN_ID) {
PrintToChat(i, "%s", buffer);
}
}
}
PrintToServer("%s", buffer);
}
public void OnClientConnected(int client) {
lastNameChange[client] = 0;
nameChangeCount[client] = 0;
firstName[client][0] = '\0';
if(!IsFakeClient(client)) {
joinTime[client] = GetTime();
GetClientName(client, firstName[client], 64 );
}
}