/******************************************
FFAC MSN Bot
hackziner

cvar :
	ffac_msn_bot_trigger //Set the trigger to send a message ( default !admin )
	ffac_msn_bot_showpub // show commands

THIS PLUGIN REQUIRES FFAC/TOOL 2.X !


Changelog:

0.3
	add pub with cvar
	add trigger cvar
	add version cvar
	replace hltv by ip
	replace "_","'" by " " 
	


contact:
http://82.232.102.55
msn: hackziner@gmail.com
aim : hackziner
*******************************************/


#include <amxmodx>
#include <amxmisc>
#include <ffac_sys>

#define PLUGIN "FFAC MSN bot"
#define VERSION "0.3"
#define AUTHOR "hackziner"

#define PUB_TASK 22215

new trigger[16]
new msn_bot_showpub

public plugin_init() 
{
	register_plugin(PLUGIN, VERSION, AUTHOR)	
	ffac_register_plugin(PLUGIN, VERSION, AUTHOR)	
	register_cvar("ffac_msn_bot_version",VERSION,FCVAR_SERVER)
	register_cvar("ffac_msn_bot_trigger","!admin")
	register_cvar("ffac_msn_bot_showpub","1") 
	register_clcmd("say", "handle_say")
	get_cvar_string("ffac_msn_bot_trigger",trigger,16) 
	msn_bot_showpub = get_cvar_num("ffac_msn_bot_showpub")
	
	if (msn_bot_showpub)
		set_task(240.0, "bot_pub", PUB_TASK, "",0, "b")
}


public handle_say(id) 
{
new said[128]

read_args(said,128)

if(  containi(said, trigger) != -1 )
	{
		new szName[32]
		new szAuthID[32]
		get_user_name(id,szName,32)
		get_user_authid(id,szAuthID,32)
		if (containi(szAuthID, "LAN") != -1 || containi(szAuthID, "HLTV") != -1 )
			get_user_ip(id,szAuthID,32)
		replace_all ( said, 127, "^"", " ")	
		replace_all ( said, 127, "'", " ")	
		ffac_msn_message2admin2(said,szAuthID,szName)
	}
	else
			if(  containi(said, "admins") != -1 )
				{
				new msncontact[32]
				get_cvar_string("ffac_msn_contact",msncontact,31)
				if(  containi(msncontact, "@") != -1 )
						print_adminlist(id) 
				else
						client_print(id,print_chat,"FFAC : No admin msn contact defined !")					
				}
}

public bot_pub()
{
client_print(0,print_chat,"To contact an server admin on MSN, type %s message",trigger)
}


//Modifed, from Admin_check by OneEyed
public print_adminlist(idp) 
{
	new id, count
	new maxplayers
	maxplayers = get_maxplayers()
	for(id = 1 ; id <= maxplayers ; id++)
		if(is_user_connected(id))
			if(get_user_flags(id) & ADMIN_KICK)
					count++

	if (count>0)
		{
		if (count==1)
			client_print(idp,print_chat,"FFAC : There is %d admin online",count)
		else
			client_print(idp,print_chat,"FFAC : There are %d admin_s online",count)
		}
	else
		client_print(idp,print_chat,"FFAC : Admins are offline, to contact an admin on msn say : !admin <message>")
}


