/*********************************************************
 * Backchannel plugin - Version 0.8                      *
 *********************************************************
 *                                                       *
 * Name: plugin_rindy_backchannel                        *
 * Author: Rinde (rinde@fiatnox.de)                      *
 * Released: 14/11/02                                    *
 *                                                       *
 *                                                       *
 * Commands:                                             *
 *                                                       *
 * admin_bc <msg>: Like admin_chat, but with typesay     *
 *                                                       *
 *                                                       *
 * Changelog:                                            *
 *                                                       *
 * Version 0.8                                           *
 *                                                       *
 *  -  Initial release                                   *
 *                                                       *
 *********************************************************/
 
/* Includes */
#include <adminlib>
 
/* Global Variables */
new g_Version[] = "0.8";
 
/* Function Declarations */
forward AdminBackchannel(HLCommand,HLData,HLUserName,UserIndex);
 
/* Event Handlers */
public plugin_init() {
    plugin_registerinfo("Rinde's Backchannel Blugin","Admin_chat with typesay.",g_Version);
    plugin_registercmd("admin_bc","AdminBackchannel",ACCESS_CHAT,"admin_bc <msg>: Prints <msg> to all admins.");
    return PLUGIN_CONTINUE;
}
 
/* Command Handlers */
public AdminBackchannel(HLCommand,HLData,HLUserName,UserIndex) {
    new Data[MAX_DATA_LENGTH];
    new User[MAX_NAME_LENGTH];
    new Word[80];
    new Message[255];
    new maxplayers = maxplayercount();
    new Linebreak;
    new i;
    convert_string(HLData,Data,MAX_DATA_LENGTH);
    if(strlen(Data) > 0) {
        convert_string(HLUserName,User,MAX_NAME_LENGTH);
        log_command(User,"admin_bc",Data);
        strcpy(Message,User,255);
        strcpy(Message,":^n",255);
        Linebreak = strlen(Data);
        while(strlen(Data) > 0) {
            strsep(Data," ",Word,80,Data,MAX_DATA_LENGTH);
            if(strlen(Message[Linebreak]) + strlen(Word) + 1 >= 79) {
                strcat(Message,"^n",255);
                Linebreak = strlen(Message);
            } else {
                strcat(Message," ",255);
            }
            strcat(Message,Word,255);
        }
        for(i=1;i<=maxplayers;i++) {
            if(playerinfo(i,User,MAX_NAME_LENGTH) == 1 && access(ACCESS_CHAT,User) == 1) {
                messageex(User,Message,print_tty);
            }
        }
    } else {
        selfmessage("You must say something.");
    }
    return PLUGIN_HANDLED;
}