PHP Code:
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
static String:sBannedDB[PLATFORM_MAX_PATH];
public OnPluginStart()
{
BuildPath(Path_SM, sBannedDB, PLATFORM_MAX_PATH, "configs/sm_tlist.ini"); //Build the path and store it in the global variable sBannedDB
RegConsoleCmd("sm_tlist",Command_tlist);
}
public OnClientPutInServer(Client)
{
decl String:Auth[64];
GetClientAuthString(Client,Auth,sizeof(Auth));
ShowBanReasonOfID(Client,Auth);
}
public bool:ShowBanReasonOfID(Client,const String:Auth[])
{
new bool:Match = false;
decl String:szAuth[32];
decl String:szReason[64];
new Handle:hKV = CreateKeyValues("Tlist");
FileToKeyValues(hKV, sBannedDB);
if (KvGotoFirstSubKey(hKV)) //Take us inside "Banning" section
{
if (KvGotoFirstSubKey(hKV)) //Take us inside the first SteamID.
{
do
{
KvGetSectionName(hKV, szAuth, sizeof(szAuth)); //Get the SteamID
if(StrContains(Auth,szAuth,false) != -1)
{
KvGetString(hKV, "reason", szReason, sizeof(szReason)); //Get the reason for banning.
PrintToChatAll("STEAM: %s REASON: %s", szAuth, szReason); //Print the message
Match = true;
}
} while (KvGotoNextKey(hKV)); //Goto the next SteamID
}
}
CloseHandle(hKV);
return Match;
}
public Action:Command_tlist(Client,Args)
{
if( Args < 2)
{
ReplyToCommand(Client,"Syntax: sm_tlist <steamid> \"<reason>\"");
}
decl String:SteamId[68];
GetCmdArg(1,SteamId,sizeof(SteamId));
new Handle:Regex = CompileRegex("STEAM_[0-9]:[0-9]:[0-9]{4,}");
if(MatchRegex(Regex,SteamId) != -1)
{
decl String:Reason[255];
GetCmdArg(2,Reason,sizeof(Reason));
new Handle:hKV = CreateKeyValues("Tlist");
FileToKeyValues(hKV, sBannedDB);
KvJumpToKey(hKV,"Banned",false);
KvJumpToKey(hKV,SteamId,true);
KvSetString(hKV,"reason",Reason);
KvRewind(hKV);
KeyValuesToFile(hKV,sBannedDB);
CloseHandle(hKV);
}else{
ReplyToCommand(Client,"SteamId doesn't match normal SteamId format");
}
}
Haven't compiled yet, so I probably forgot some things/made typos.
I haven't autokicked after ShowBanReason yet, I leave that up to you
__________________