/* ===============================================================
Créditos: roccoxx.
=============================================================== */
#include <amxmodx>
#include <amxmisc>
new const szRegisterPlugin[ ][ ] = { "Color Say", "1.1", "kikizon" }; // Edit: Sky^^
new const szPrefix[ ][ ] = { "\d[\y AMXX\d ]\w", "^3[ AMXX ]^1" }; // 0 = Prefix Menu // 1 = Prefix Say
new gSayColors[ 33 ];
/* =============================================================== */
public plugin_init( )
{
register_plugin( szRegisterPlugin[ 0 ], szRegisterPlugin[ 1 ], szRegisterPlugin[ 2 ] );
register_clcmd( "say /colores", "openMenuColors" );
register_clcmd( "say", "clcmd_HookSay" );
}
public client_putinserver( id ) gSayColors[ id ] = 1;
/* =============================================================== */
public openMenuColors( id )
{
if( !is_user_admin( id ) )
{
cc( id, "%s Menú disponible solo para administradores.", szPrefix[ 1 ] );
return PLUGIN_HANDLED;
}
new iColor[ 512 ], fMenu[ 512 ], iMenu;
switch( gSayColors[ id ] )
{
case 1: iColor = "Amarillo";
case 2:
{
if( get_user_team( id ) == 1 )
iColor = "Rojo";
else if( get_user_team( id ) == 2 )
iColor = "Azul";
}
case 3: iColor = "Verde";
}
formatex( fMenu, charsmax( fMenu ), "%s Menu de colores para el Say^n\dTu color actual es:\y %s", szPrefix[ 0 ], iColor );
iMenu = menu_create( fMenu, "handMenuColors" );
menu_additem( iMenu, ( gSayColors[ id ] == 1 ) ? "\dAmarillo" : "Amarillo", "1" );
if( get_user_team( id ) == 1 ) menu_additem( iMenu, ( gSayColors[ id ] == 2 ) ? "\dRojo" : "Rojo", "2" );
else if( get_user_team( id ) == 2 ) menu_additem( iMenu, ( gSayColors[ id ] == 2 ) ? "\dAzul" : "Azul", "2" );
menu_additem( iMenu, ( gSayColors[ id ] == 3 ) ? "\dVerde" : "Verde", "3" );
menu_setprop( iMenu, MPROP_EXITNAME, "Salir" );
menu_display( id, iMenu, 0 );
return PLUGIN_HANDLED;
}
public handMenuColors( id, menu, item )
{
switch( item )
{
case 0:
{
if( gSayColors[ id ] == 1 )
{
cc( id, "%s Ya tienes este color.", szPrefix[ 1 ] );
openMenuColors( id );
}
else
gSayColors[ id ] = 1;
}
case 1:
{
if( gSayColors[ id ] == 2 )
{
cc( id, "%s Ya tienes este color.", szPrefix[ 1 ] );
openMenuColors( id );
}
else
gSayColors[ id ] = 2;
}
case 2:
{
if( gSayColors[ id ] == 3 )
{
cc( id, "%s Ya tienes este color.", szPrefix[ 1 ] );
openMenuColors( id );
}
else
gSayColors[ id ] = 3;
}
case MENU_EXIT: { menu_destroy( menu ); return PLUGIN_HANDLED; }
}
menu_destroy( menu );
return PLUGIN_HANDLED;
}
/* =============================================================== */
public clcmd_HookSay( id )
{
static iChat[ 191 ];
read_args( iChat, charsmax( iChat ) );
remove_quotes( iChat );
replace_all( iChat, charsmax( iChat ), "%", " " );
if( !ValidMessage( iChat, 1 ) ) return PLUGIN_CONTINUE;
new iName[ 32 ], iMessage[ 256 ], iSayColors[ 6 ];
get_user_name( id, iName, 31 );
switch( gSayColors[ id ] )
{
case 1: iSayColors = "^x01";
case 2: iSayColors = "^x03";
case 3: iSayColors = "^x04";
}
if( is_user_admin( id ) )
{
format( iMessage, 255, "%s[^x04 ADMIN^x03 ] %s:%s %s", is_user_alive( id ) ? "^x03" : "^x03[ MUERTO ] ", iName, iSayColors, iChat );
color_chat( 0, id, iMessage );
console_print( 0, iMessage );
}
else
{
format( iMessage, 255, "%s %s^x01: %s", is_user_alive( id ) ? "^x03" : "^x03[ MUERTO ]", iName, iChat );
color_chat( 0, id, iMessage );
console_print( 0, iMessage );
}
return PLUGIN_HANDLED_MAIN;
}
public color_chat( playerid, colorid, message[ ] )
{
message_begin( playerid ? MSG_ONE : MSG_ALL, get_user_msgid( "SayText" ), { 0, 0, 0 }, playerid );
write_byte( colorid );
write_string( message );
message_end( );
}
/* =============================================================== */
stock cc( id, const input[ ], any:... )
{
static szMsg[ 191 ], msgSayText;
if( !msgSayText )
msgSayText = get_user_msgid( "SayText" );
vformat( szMsg, 190, input, 3 );
replace_all( szMsg, 190, "!g", "^4" );
replace_all( szMsg, 190, "!y", "^1" );
replace_all( szMsg, 190, "!team", "^3" );
message_begin( id ? MSG_ONE_UNRELIABLE : MSG_BROADCAST, msgSayText, .player = id );
write_byte( id ? id : 33 );
write_string( szMsg );
message_end( );
}
stock ValidMessage( text[ ], maxcount )
{
static len, i, count;
len = strlen( text );
count = 0;
if( !len ) return false;
for( i = 0; i < len; i++ )
{
if( text[ i ] != ' ' )
{
count++;
if( count >= maxcount ) return true;
}
}
return false;
}