/* plugin_clanchat.sma
// DSLR - Kosh Vorlon
// Kosh_Vorlon@Mindspring.com
// http://www.dslreports.com/useremail/u/168446
// Updated: 07/31/2001
// This plugin will allow clan members to talk to each other in game without
// public members of the game seeing it. I have set the access level to the same
// level as admin_gag and admin_ungag, change it if you please. Only people in your
// user.ini file that have access to admin_gag will see or be able to use this
// feature. I created this program to help us watch for cheaters, not to be used 
// as a cheat. From the console admin_clanchat <msg>
//
// ***** NOTICE *****
// If you want to log not only what is being said, but who is saying it. In
// case you find a clan member is using it for cheating purposes, you can do
// the following.
//
// Add this to your declaration area:
// new Command[MAX_COMMAND_LENGTH];
// convert_string(HLCommand,Command,MAX_COMMAND_LENGTH);
//
// Then Change
// log(Text);
// to
// log_command(User,Command,Data);
//
// Then you can go into the cstrike/log area and
//
// cat * | grep "ADMIN Command" > admin.log
// cat admin.log | grep "admin_clanchat" > clanchat.log
// cat clanchat.log
//
// You should get messages that look like this:
//
// L 07/21/2001 - 14:02:56: [ADMIN] ADMIN Command: [ClanMsg]JoePlayer used command admin_clanchat Yeah, this is neat
*/
 
#include <core>
#include <console>
#include <string>
#include <admin>
#include <adminlib>
 
new STRING_VERSION[MAX_DATA_LENGTH] = "2.50.0";
 
#define ACCESS_CLAN 2048
 
public admin_clanchat(HLCommand,HLData,HLUserName,UserIndex) {
        new i;
        new maxplayers = maxplayercount();
        new Data[MAX_DATA_LENGTH];
        new Name[MAX_NAME_LENGTH];
        new SessionID;
        new Team;
        new Text[MAX_TEXT_LENGTH];
        new User[MAX_NAME_LENGTH];
        new WONID;
 
        convert_string(HLData,Data,MAX_DATA_LENGTH);
        convert_string(HLUserName,User,MAX_NAME_LENGTH);
        snprintf(Text, MAX_TEXT_LENGTH, "(ClanMsg) %s: %s", User, Data);
        for(i=1; i<=maxplayers; i++) {
                strinit(Name);
                if(playerinfo(i,Name,MAX_NAME_LENGTH,SessionID,WONID,Team)==1) {
                        if(access(ACCESS_CLAN,Name)!=0) {
                                messageex(Name, Text, print_chat);
                        }
                }
        }
        log(Text);
        return PLUGIN_HANDLED;
}
 
public plugin_init() {
        plugin_registerinfo("Plugin for clan Clan Chat.","Commands for clan Clan Chat.",STRING_VERSION);
 
	plugin_registercmd("admin_clanchat","admin_clanchat",ACCESS_CLAN,"admin_clanchat <msg>: Shows message only to other Clan members.");
 
	return PLUGIN_CONTINUE;
}