/* $Id: plugin_ghostchat.sma,v 1.0 2001/04/07 11:42:32 [WHO]Them Exp $ */
 
#include <core>
#include <console>
#include <string>
#include <admin>
#include <adminlib>
 
new STRING_VERSION[MAX_DATA_LENGTH] = "2.50.0";
 
new ghostchat = 1;
 
#define ACCESS_GHOSTSAY 0
 
public admin_ghostchat(HLCommand,HLData,HLUserName,UserIndex) {
	new Command[MAX_COMMAND_LENGTH];
	new Data[MAX_DATA_LENGTH];
	new User[MAX_NAME_LENGTH];
 
	convert_string(HLCommand,Command,MAX_COMMAND_LENGTH);
	convert_string(HLData,Data,MAX_DATA_LENGTH);
	convert_string(HLUserName,User,MAX_NAME_LENGTH);
 
        //if( strncmp(Data,"timeleft", strlen("timeleft"))==0) return PLUGIN_CONTINUE;
	//if( strncmp(Data,"vote", strlen("vote"))==0) return PLUGIN_CONTINUE;
        //if( strncmp(Data,"score", strlen("score"))==0) return PLUGIN_CONTINUE;
        //if( strncmp(Data,"punish", strlen("punish"))==0) return PLUGIN_CONTINUE;
        //if( strncmp(Data,"forgive", strlen("forgive"))==0) return PLUGIN_CONTINUE;
	if(ghostchat == 1) {
		ghost_chat(Data, User);
                //return PLUGIN_HANDLED;
        }
        return PLUGIN_CONTINUE;
}
 
public ghost_chat(a[], user[]) {
        new outputmessage[MAX_DATA_LENGTH];
        new i;
        new maxplayers;
        new targetname[MAX_NAME_LENGTH];
        new fakewon;
        new fakeid;
        new faketeam;
        new alivedead = -1;
        new playeralivedead = -1;
        maxplayers = maxplayercount();
        get_userindex(user, i);
        playerinfo(i, targetname, MAX_DATA_LENGTH, fakeid, fakewon, faketeam, playeralivedead);
        if(playeralivedead == 0) {
                strcpy(outputmessage, "*ALIVE*",MAX_DATA_LENGTH);
                strcat(outputmessage, user,MAX_DATA_LENGTH);
        } else {
        	strcpy(outputmessage, "*DEAD*",MAX_DATA_LENGTH);
                strcat(outputmessage, user,MAX_DATA_LENGTH);
        }
        strcat(outputmessage, " :    ", MAX_DATA_LENGTH);
        strcat(outputmessage, a, MAX_DATA_LENGTH);
        for(i=1; i <= maxplayers;i++) {
                if(playerinfo(i, targetname, MAX_DATA_LENGTH, fakeid, fakewon, faketeam, alivedead) == 1){
                	if(alivedead != playeralivedead) {
                                messageex(targetname, outputmessage, print_chat);
                        }
                }
        }
}
 
 
public plugin_init() {
	plugin_registerinfo("Ghost Chat Plugin","Lets everyone hear everyone else, alive or dead",STRING_VERSION);
	plugin_registercmd("say","admin_ghostchat",ACCESS_GHOSTSAY,"Ghost chat: allows everyone to hear everyone else, alive or dead");
        return PLUGIN_CONTINUE;
}