/* ====================================================================================*//* 
Well, the plugin is basically divided into 6 functions are:

1. amx_spam_kick it's in 4, the player will have 4 opportunities for no spam, but
yes the player spam more than 4 times, will be kicked automatically.
2. amx_spam_kick it's in 3, the player will have 3 opportunities for no spam, but
yes the player spam more than 3 times, will be kicked automatically.
3. amx_spam_kick it's in 2, the player will have 2 opportunities for no spam, but
yes the player spam more than 2 times, will be kicked automatically.
4. amx_spam_kick it's in 1, the player will have 1 opportunity for no spam, but
yes the player spam more than 1 time, will be kicked automatically.
5. if the cvar amx_spam_kick it's in 5 or more, the words do not appear
6. if the cvar amx_spam_kick it's in 0, spam block it's off.

* The words that you want to say you should add in the default file
spam.ini

========================================================================================*/
#include <amxmodx>
#include <amxmisc>

#define SERVER_KICK server_cmd("kick #%d ^"You cannot spam here!^"", get_user_userid(id) );

new more[33], _server_kick, Args[ 621 ], buffer[ 32 ], Array:g_spam;

public plugin_init(){
	register_plugin( "Spam kick", "1.2", "g_often" );
	
	register_clcmd( "say", "SpamKick" );
	register_clcmd( "say_team", "SpamKick" );
	
	register_dictionary( "spam.txt" )
	
	g_spam = ArrayCreate( 32, 1 );
	_server_kick = register_cvar( "amx_spam_kick", "4" );
	
	load_spam();
}

public client_putinserver( id ) more[ id ] = 0;

public SpamKick( id )
{
	new serverkick = get_pcvar_num( _server_kick )
	read_args( Args , 620 );
	
	
	if(!is_user_admin(id))
	{
	
		for (new i = 0 ; i < ArraySize( g_spam ) ; i++)
		{
			ArrayGetString( g_spam , i , buffer , 31 )
			if ( containi ( Args , buffer ) != -1)
			{
				more[ id ]++
				{
					if( serverkick == 4 )
					{
						if(more[ id ] == 1) client_print( id, print_chat, "%L", LANG_PLAYER, "WARNING_FOURTH1" );
						if(more[ id ] == 2) client_print( id, print_chat, "%L", LANG_PLAYER, "WARNING_FOURTH2" );
						if(more[ id ] == 3) client_print( id, print_chat, "%L", LANG_PLAYER, "WARNING_FOURTH3" );
						if(more[ id ] >= 4) SERVER_KICK return 1;
					}
					if( serverkick == 3 )
					{
						if(more[ id ] == 1) client_print( id, print_chat, "%L", LANG_PLAYER, "WARNING_THIRD1" );
						if(more[ id ] == 2) client_print( id, print_chat, "%L", LANG_PLAYER, "WARNING_THIRD2" );
						if(more[ id ] >= 3) SERVER_KICK return 1;
					}
					if(serverkick == 2)
					{
						if(more[ id ] == 1) client_print( id, print_chat, "%L", LANG_PLAYER, "WARNING_KICK" );
						if(more[ id ] >= 2) SERVER_KICK return 1;
					}
				}
				
				if(serverkick > 4)  return 1;
				
				if (serverkick  ==  1) { SERVER_KICK return 1; }
				
				else if(serverkick == 0) break;
			}
		}
		return PLUGIN_CONTINUE
	}
	else return 0;
	
	return PLUGIN_HANDLED;
}
public load_spam()
{
	new archive[ 32 ], file_spam[ 64 ];
	get_configsdir ( archive , 31 );
	formatex ( file_spam , 63 , "%s/spam.ini" , archive );
	if( file_exists ( file_spam ) ) 
	{
		new linea[ 128 ], file = fopen( file_spam , "rt")
		
		if(file)
		{
			while ( file && !feof( file ) ) 
			{
				fgets( file , linea , 127 )
				replace( linea , 127 , "^n" , "" )
				if ( ( linea[ 0 ] == '/' && linea[ 1 ] == '/') || linea[ 0 ] == ';' || strlen( linea ) < 1) continue;
				
				ArrayPushString( g_spam , linea )
			}
		}
		fclose( file )
	}
}  
