You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
95 lines
2.5 KiB
95 lines
2.5 KiB
#include <sourcemod>
|
|
#include <sdktools>
|
|
#define PLUGIN_VERSION "1.1"
|
|
|
|
public Plugin:myinfo = {
|
|
name = "[ANY] Bad Nicknames",
|
|
author = "gsd",
|
|
description = "Kick users have substring from DataBase",
|
|
version = PLUGIN_VERSION,
|
|
url = "https://kremlin.ru"
|
|
};
|
|
|
|
//void KickClient(int client, const char[] format, any... ...)
|
|
//bool GetClientName(int client, char[] name, int maxlen)
|
|
|
|
new Handle:hDatabase = INVALID_HANDLE;
|
|
new Handle:gReason = INVALID_HANDLE;
|
|
|
|
char g_IgnoreOverride[32] = "sm_bdn_override";
|
|
|
|
public OnPluginStart() {
|
|
//VerifyTable();
|
|
StartSQL();
|
|
CreateConVar("sm_bdn_version", PLUGIN_VERSION, "Bad Nicknames Version", FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
|
|
gReason = CreateConVar("sm_bdn_reason", "Change you nickname before connect to server...\nYou nickname is trash. Have not funny meme or trade sites.", "Kick reason");
|
|
}
|
|
|
|
StartSQL() {
|
|
SQL_TConnect(GotDatabase, "bad_nicknames");
|
|
}
|
|
|
|
public GotDatabase(Handle:owner, Handle:hndl, const String:error[], any:data) {
|
|
if (hndl == INVALID_HANDLE) {
|
|
LogError("Database Connection Error: %s", error);
|
|
} else {
|
|
hDatabase = hndl;
|
|
}
|
|
}
|
|
|
|
public T_Check(Handle:owner, Handle:hndl, const String:error[], any:data) {
|
|
if (hndl == INVALID_HANDLE) {
|
|
LogError("Query failed! %s", error);
|
|
}
|
|
return;
|
|
}
|
|
|
|
public OnClientPostAdminCheck(client) {
|
|
//User Connect to Server
|
|
if(IsFakeClient(client)) {
|
|
return;
|
|
}
|
|
//Vars
|
|
char player_name[64];
|
|
char query[1024];
|
|
|
|
//Get Vars
|
|
GetClientName(client, player_name, sizeof(player_name));
|
|
|
|
//Get SQL Vars
|
|
char dbs_player_name[64];
|
|
SQL_EscapeString(hDatabase, player_name, dbs_player_name, 64)
|
|
|
|
//Format SQL
|
|
//SELECT `comment` FROM `bad_nicknames` WHERE LOCATE(`substr`, 'pelmen trade');
|
|
Format(query, sizeof(query), "SELECT comment FROM bad_nicknames WHERE position(substr in '%s')>0", dbs_player_name);
|
|
|
|
//Function
|
|
SQL_TQuery(hDatabase, T_CheckPlayer, query, GetClientUserId(client));
|
|
}
|
|
|
|
public T_CheckPlayer(Handle:owner, Handle:hndl, const String:error[], any:data) {
|
|
|
|
new client;
|
|
if ((client = GetClientOfUserId(data)) == 0) {
|
|
return;
|
|
}
|
|
|
|
char player_name[64];
|
|
GetClientName(client, player_name, sizeof(player_name));
|
|
|
|
char reason[256];
|
|
GetConVarString(gReason, reason, sizeof(reason));
|
|
|
|
if (SQL_GetRowCount(hndl) > 0) {
|
|
//KickClient(client, reason);
|
|
if(CheckCommandAccess(client, g_IgnoreOverride, ADMFLAG_ROOT)){
|
|
return;
|
|
} else {
|
|
SetClientName(client, "facti13 player");
|
|
}
|
|
LogMessage("%s kicked from server. Nickname invalid, have trade link or other string.", player_name);
|
|
return;
|
|
}
|
|
return;
|
|
}
|