/*
version 1.0.0 02/11/02
This is plugin to remember player's original name define by his ID
and be able to recover it even if he changed his name.
Should help eliminate peoples talking bs about clan, server etc. under new
name and thinking that nobody can recognize them.
To check player: admin_who <player>
To add player to the list: admin_addname <player> <name_to_remember>
plugin require file iknowyou.txt with '*' character in the last line (end of the file) in cstrike directory
by j23 (ssp@ssp.tzo.com)
*/
 
/* Should be compatible with steam now. But untested though! [WING] Black Knight */
 
#include <core>
#include <console>
#include <string>
#include <admin>
#include <adminlib>
 
new String_Version[MAX_DATA_LENGTH]="1.0.0";
 
public admin_who_are_you(HLCommand,HLData,HLUser,UserIndex)
{
	new data[MAX_NAME_LENGTH];
	new name[MAX_NAME_LENGTH];
	new realname[MAX_NAME_LENGTH];
	new sAuthID[MAX_AUTHID_LENGTH];
	new knownAuthID[MAX_AUTHID_LENGTH];
	new iknowyou[MAX_TEXT_LENGTH];
	new msg[MAX_TEXT_LENGTH];
 
	convert_string(HLData,data,MAX_NAME_LENGTH);
 
	if(check_user(data)==1)
	{
	get_username(data,name,MAX_NAME_LENGTH);
	get_userAuthID(name,sAuthID);
	new n=1;
	do
		{
		readfile("iknowyou.txt",iknowyou,n,MAX_TEXT_LENGTH);
		strsplit(iknowyou,":",knownAuthID,MAX_AUTHID_LENGTH,realname,MAX_NAME_LENGTH);
		if(streq(sAuthID,knownAuthID)==1)
			{
			snprintf(msg,MAX_TEXT_LENGTH,"Who? %s. Yes, I know him.^nHis old name is %s",name,realname);
			selfmessage(msg);
			return PLUGIN_HANDLED;
			}
		n++;
		}
	while(streq(iknowyou,"*")!=1);
	snprintf(msg,MAX_TEXT_LENGTH,"%s - doesn't ring the bell.^nHe is not on the list",name);
	selfmessage(msg);
	}
	else
	{
	selfmessage("Unrecognized player: ");
	selfmessage(data);
	}
	return PLUGIN_HANDLED;
}
 
public admin_add_player(HLCommand,HLData,HLPlayer,UserIndex)
{
	new data[MAX_DATA_LENGTH];
	new name[MAX_NAME_LENGTH];
	new newname[MAX_NAME_LENGTH];
	new realname[MAX_NAME_LENGTH];
	new sAuthID[MAX_AUTHID_LENGTH];
	new iknowyou[MAX_TEXT_LENGTH];
	new knownAuthID[MAX_AUTHID_LENGTH];
	new knowname[MAX_NAME_LENGTH];
	new msg[MAX_TEXT_LENGTH];
 
	convert_string(HLData,data,MAX_DATA_LENGTH);
 
	strsep(data," ",name,MAX_NAME_LENGTH,newname,MAX_NAME_LENGTH);
	if(check_user(name)==1)
	{
	get_username(name,realname,MAX_NAME_LENGTH);
	get_userAuthID(realname,sAuthID);
	new n=1;
	do
		{
		readfile("iknowyou.txt",iknowyou,n,MAX_TEXT_LENGTH);
		strsplit(iknowyou,":",knownAuthID,MAX_AUTHID_LENGTH,knowname,MAX_NAME_LENGTH);
		if(streq(sAuthID,knownAuthID)==1)
			{
			snprintf(msg,MAX_TEXT_LENGTH,"Hey, loosing memory? %s is already on the list as %s",realname,knowname);
			selfmessage(msg);
			return PLUGIN_HANDLED;
			}
		n++;
		}
	while(streq(iknowyou,"*")!=1);
	iknowyou="";
	strcat(iknowyou,sAuthID,MAX_TEXT_LENGTH);
	strcat(iknowyou,":",MAX_TEXT_LENGTH);
	strcat(iknowyou,newname,MAX_TEXT_LENGTH);
	writefile("iknowyou.txt",iknowyou,n-1);
	writefile("iknowyou.txt","*",n);
	snprintf(msg,MAX_TEXT_LENGTH,"%s added to the known users list as %s",realname,newname);
	selfmessage(msg);
	}
	else
	{
	selfmessage("Unrecognized player: ");
	selfmessage(data);
	}
	return PLUGIN_HANDLED;
}
 
public plugin_init()
{
 
	plugin_registerinfo("Do I know him?","Checking if player just change name to make fun of us",String_Version);
	plugin_registercmd("admin_who","admin_who_are_you",ACCESS_IMMUNITY,"admin_who <playername>");
	plugin_registercmd("admin_addname","admin_add_player",ACCESS_IMMUNITY,"admin_addname <playername> <name_to_remember>");
	return PLUGIN_CONTINUE;
}