/*
Copyright (C) 2002, Weaselweb
Date: January,24 2002
Author: Weaselweb <weaselweb@counterstrike.de><http://www.weaselweb.de.vu>
Command: admin_look
Version: 1.1
 
admin_look will show the players,who's ID and Nick is written into the LOOK.TXT.
It will be compared with their current nicks on the server. Usefull to see,if someone has
changed or faked nick,even admins with level 131071 :)
Only players with access-level 128 will be able to use the plugin.
 
Installing:
	-copy "plugin_weasel_look.amx"(Win32) or "plugin_weasel_look_l.amx"(Linux) in your /dlls dir
	-for Linux: rename the file into "plugin_weasel_look.amx" like the Win32 file :-)
	-write dlls/plugin_weasel_look.amx in your plugin.ini
	-create this LOOK.TXT in your mod-dir, where your (listen)server.cfg is located
	-edit the LOOK.TXT as shown below
	-ready!
 
Notice!
	-in every case "file_read_acces 1" has to be in your (listen)server.cfg
 
Improvements/Changes in V1.1:
	-only these Players will be shown,which have really a faked nick
	-if no player has a faked nick,a massege will be shown that it is so
	-Access-level 128 is required instead of 256 !!!!!
	-better Documentation ;-)
 
Thanks to Cooper for this idea
 
Format of LOOK.TXT:
 
WONIP[variable digit number] [one space]Name[just you want]
e.g.
9897345873 It's me
 
1 entry per line!!
 
On Linux Servers you might have to write LOOK.TXT,because of
case sensitive.I don't know exactly,just heard about.
 
It would be great,if i can find someone,who test with me this(or later other) plugin
on Linux systems,because i have Win32. So on the other side,i can't debug on this system.
 
Enjoy my first plugin and please mail me suggestions, bugs(!), imprvoements, comments or what you want
 
Hope i didn' fotget anything ;-)
 
 
*/
 
/* Should be compatible with steam now. But untested though! [WING] Black Knight*/
 
#include <core>
#include <console>
#include <string>
#include <admin>
#include <adminlib>
 
#define ACCESS_LOOK 128  // security level to see the "faked" nick
 
new STRING_VERSION[MAX_DATA_LENGTH] = "2.50.11";
new TextFile[MAX_DATA_LENGTH];
new LOOK_COUNTER = 0;
 
public admin_look(HLCommand,HLData,HLUserName,UserIndex) {
	new i;
	new j;
	new maxplayers = maxplayercount();
	new Name[MAX_NAME_LENGTH];
	new Text[MAX_TEXT_LENGTH];
	new User[MAX_NAME_LENGTH];
	new Data[MAX_DATA_LENGTH];
	new Command[MAX_COMMAND_LENGTH];
	new k=0;
	new sAuthID[MAX_AUTHID_LENGTH];
	new sAuthID2[MAX_AUTHID_LENGTH];
 
        convert_string(HLCommand,Command,MAX_COMMAND_LENGTH);
        convert_string(HLData,Data,MAX_DATA_LENGTH);
        convert_string(HLUserName,User,MAX_NAME_LENGTH);
 
	if (fileexists(TextFile) == 1) {
	        selfmessage( "------------ Player: ------------");
		new strMessage[MAX_DATA_LENGTH];
		for(j=1; j <= LOOK_COUNTER; j++) {
			for(i=1; i<=maxplayers; i++) {
				strinit(Name);
				if(playerinfo(i,Name,MAX_NAME_LENGTH)==1) {
					if (readfile(TextFile, strMessage, j, MAX_TEXT_LENGTH) != 0) {
						strbreak(strMessage, sAuthID2, strMessage, MAX_TEXT_LENGTH);
						get_userAuthID(Name,sAuthID,MAX_AUTHID_LENGTH);
						if (streq(sAuthID,sAuthID2)) {
							if (streq(strMessage, Name)==0) {
								snprintf(Text, MAX_TEXT_LENGTH, "%s plays as %s", strMessage, Name);
								selfmessage(Text);
								k++;
							}
						}
					}
				}
			}
		}
	} else {
		selfmessage("Can not find LOOK.TXT");
	}
	if (k == 0) {
		snprintf(Text, MAX_TEXT_LENGTH, "No known player has a faked nick.");
		selfmessage(Text);
	}
	log_command(User,Command,Data);
	return PLUGIN_HANDLED;
}
 
public plugin_init() {
	plugin_registerinfo("Weaselweb's admin_look Plugin","admin_look",STRING_VERSION);
	plugin_registercmd("admin_look","admin_look",ACCESS_LOOK,"admin_look: Shows known players with their current nick.");
 
	strcpy(TextFile, "LOOK.TXT", MAX_DATA_LENGTH);
 
	if (fileexists(TextFile) == 1) {
    		LOOK_COUNTER = filesize(TextFile, lines);
  	} else {
    		LOOK_COUNTER = 0;
  	}
	return PLUGIN_CONTINUE;
}