#include < amxmodx >
#include < amxmisc >
#include < hamsandwich >
#include < fakemeta >
#define ICHAT_VERSION "2.2.1"
#pragma semicolon 1
#define MAX_PLAYERS 32
#define TASK_NOTIFY 5987
#define NOTIFY_TASK_TIME 15.0
#define FORMAT_MAX_SIZE 264
#define FORMAT_SMALL_MAX_SIZE 36
#define MAX_CUSTOM_TAGS 2
#define MAX_CUSTOM_TAGS_SIZE 24
enum _:formats
{
formatAllDefAlive = 0,
formatAllFundadorAlive
formatAllAdminAlive,
formatAllVIPAlive,
formatTeamDefAlive,
formatTeamFundadorAlive
formatTeamAdminAlive,
formatTeamVIPAlive,
formatAllDefDead,
formatAllFundadorDead,
formatAllAdminDead,
formatAllVIPDead,
formatTeamDefDead,
formatTeamFundadorDead,
formatTeamAdminDead,
formatTeamVIPDead,
formatMeMessage,
formatMeCommand,
formatClearCommand,
formatMax
};
enum _:formatTypes { formatDefAlive = 0, formatDefDead, formatTeamAlive, formatTeamDead, formatTypesMax };
enum _:messageType { messageToAll = 0, messageToTeam };
enum _:formatMode { USER = 0, Fundador, ADMIN, VIP, CUSTOM };
enum _:teamTags { T = 1, CT, SPEC };
enum _:deadOrAlive { DEAD = 0, ALIVE };
enum _:usersFlags { FLAG_RELOAD = 0, FLAG_SPY, FLAG_Fundador, FLAG_ADMIN, FLAG_VIP, FLAG_CHAT, FLAG_SEE_CHAT };
new gszChatFormats[ formatMax ][ FORMAT_MAX_SIZE ];
new gszFormatTeamTags[ SPEC + 1 ][ ALIVE + 1 ][ FORMAT_SMALL_MAX_SIZE ];
new gszAccesFlags[ FLAG_SEE_CHAT + 1 ][ 26 ];
new gszCustomTags[ MAX_PLAYERS + 1 ][ MAX_CUSTOM_TAGS ][ MAX_CUSTOM_TAGS_SIZE ];
new gszAuthid[ MAX_PLAYERS + 1 ][ 35 ];
new Trie:gtCustomFormats[ formatTypesMax ];
new Trie:gtCustomFormatEnabled[ formatTypesMax ];
new giRemoveOnSlash;
new giUserNotify;
new giAdminsSpy;
new giUseCustomColor;
new giRemoveNameChanged;
new giRed;
new giGreen;
new giBlue;
new giPunishment;
new giAllTalk;
new giUseCustomTags;
new giUseCustomFormats;
new Float:gFlPrintRadiusAll;
new Float:gFlPrintRadiusTeam;
new gBitIsFirstSpawn;
#define SetUserFirstSpawn(%1) gBitIsFirstSpawn |= 1 << ( %1 & 31 )
#define ClearUserFirstSpawn(%1) gBitIsFirstSpawn &= ~( 1 << ( %1 & 31 ) )
#define IsFirstSpawn(%1) gBitIsFirstSpawn & 1 << ( %1 & 31 )
new gBitIsChatOn;
#define EnableUserChat(%1) gBitIsChatOn |= 1 << ( %1 & 31 )
#define DisableUserChat(%1) gBitIsChatOn &= ~( 1 << ( %1 & 31 ) )
#define IsUserChatEnabled(%1) gBitIsChatOn & 1 << ( %1 & 31 )
new gBitIsVip;
#define SetUserVip(%1) gBitIsVip & 1 << ( %1 & 31 )
#define ClearUserVip(%1) gBitIsVip & 1 << ( %1 & 31 )
#define IsUserVip(%1) gBitIsVip & 1 << ( %1 & 31 )
new giLocation;
new gszLocation[ MAX_PLAYERS + 1 ][ FORMAT_SMALL_MAX_SIZE ];
new gMsgSayText, gMsgTeamInfo;
public plugin_init( )
{
register_plugin( "iChat", ICHAT_VERSION, "Kid" );
register_dictionary( "iChat.txt" );
register_dictionary( "common.txt" );
gMsgSayText = get_user_msgid( "SayText" );
gMsgTeamInfo = get_user_msgid( "TeamInfo" );
register_message( gMsgSayText, "iChatMessageSayText" );
RegisterHam( Ham_Spawn, "player", "iChatPlayerSpawn", 1 );
register_concmd( "amx_reload_ichat", "iChatReloadConfig" );
register_clcmd( "say", "iChatHookSay", 0 );
register_clcmd( "say_team", "iChatHookSay", 1 );
new szModShortName[ 7 ];
if ( get_modname( szModShortName, charsmax( szModShortName ) ) == 5
&& equal( szModShortName, "czero" ) )
{
register_event( "Location", "iChatEventLocation", "be" );
}
new iSutppCvar = register_cvar( "ichat_version", ICHAT_VERSION, FCVAR_SERVER | FCVAR_EXTDLL | FCVAR_SPONLY );
set_pcvar_string( iSutppCvar, ICHAT_VERSION );
new iFormatType;
for ( iFormatType = 0; iFormatType < formatTypesMax; iFormatType++ )
{
gtCustomFormats[ iFormatType ] = TrieCreate( );
gtCustomFormatEnabled[ iFormatType ] = TrieCreate( );
}
iChatConfig( );
}
public plugin_natives( )
{
register_library( "iChat" );
register_native( "iChatSendCustomData", "iChatSendCustomData" );
register_native( "iChatVipAction", "iChatVipAction" );
}
public iChatReloadConfig( id )
{
if ( !has_flag( id, gszAccesFlags[ FLAG_RELOAD ] ) && gszAccesFlags[ FLAG_RELOAD ][ 0 ] )
{
client_print( id, print_console, "%L", id, "NO_ACC_COM" );
return PLUGIN_HANDLED_MAIN;
}
iChatConfig( );
client_print( id, print_console, "[iChat] %L", id, "RELOADED" );
return PLUGIN_CONTINUE;
}
public iChatConfig( )
{
new szCfgFile[ 128 ];
get_configsdir( szCfgFile, charsmax( szCfgFile ) );
formatex( szCfgFile, charsmax( szCfgFile ), "%s/ichat.cfg", szCfgFile );
new iCfgFileHandle = fopen( szCfgFile, "rt" );
if ( !iCfgFileHandle )
{
set_fail_state( "No configuration file" );
return;
}
new szLineData[ 364 ], szLineKey[ 96 ], szLineValue[ 264 ];
while ( !feof( iCfgFileHandle ) )
{
fgets( iCfgFileHandle, szLineData, charsmax( szLineData ) );
trim( szLineData );
if ( szLineData[ 0 ] == ';' || szLineData[ 0 ] == '#' || ( szLineData[ 0 ] == '/' && szLineData[ 1 ] == '/' ) || !szLineData[ 0 ] )
{
continue;
}
parse( szLineData, szLineKey, charsmax( szLineKey ), szLineValue, charsmax( szLineValue ) );
switch ( szLineKey[ 0 ] )
{
case 'F':
{
switch ( szLineKey[ 7 ] )
{
case 'D':
{
switch ( szLineKey[ 11 ] )
{
case 'A':
{
if ( equal( szLineKey, "FORMAT_DEF_ALIVE" ) )
{
copy( gszChatFormats[ formatAllDefAlive ], charsmax( gszChatFormats[ ] ), szLineValue );
}
}
case 'F':
{
if ( equal( szLineKey, "FORMAT_DEF_DEAD" ) )
{
copy( gszChatFormats[ formatAllDefDead ], charsmax( gszChatFormats[ ] ), szLineValue );
}
}
}
}
case 'F':
{
if ( equal( szLineKey, "FORMAT_Fundador_ALIVE" ) )
{
copy( gszChatFormats[ formatAllAdminAlive ], charsmax( gszChatFormats[ ] ), szLineValue );
switch ( szLineKey[ 13 ] )
}
if ( equal( szLineKey, "FORMAT_Fundador_DEAD" ) )
{
copy( gszChatFormats[ formatAllAdminDead ], charsmax( gszChatFormats[ ] ), szLineValue );
}
case 'D':
{
if ( equal( szLineKey, "FORMAT_ADMIN_DEAD" ) )
{
copy( gszChatFormats[ formatAllAdminDead ], charsmax( gszChatFormats[ ] ), szLineValue );
case 'D':
{
if ( equal( szLineKey, "FORMAT_ADMIN_DEAD" ) )
{
copy( gszChatFormats[ formatAllAdminDead ], charsmax( gszChatFormats[ ] ), szLineValue );
}
}
}
}
case 'V':
{
switch ( szLineKey[ 11 ] )
{
case 'A':
{
if ( equal( szLineKey, "FORMAT_VIP_ALIVE" ) )
{
copy( gszChatFormats[ formatAllVIPAlive ], charsmax( gszChatFormats[ ] ), szLineValue );
}
}
case 'D':
{
if ( equal( szLineKey, "FORMAT_VIP_DEAD" ) )
{
copy( gszChatFormats[ formatAllVIPDead ], charsmax( gszChatFormats[ ] ), szLineValue );
}
}
}
switch ( szLineKey[ 12 ] )
{
case 'D':
{
switch ( szLineKey[ 16 ] )
{
case 'A':
{
if ( equal( szLineKey, "FORMAT_TEAM_DEF_ALIVE" ) )
{
copy( gszChatFormats[ formatTeamDefAlive ], charsmax( gszChatFormats[ ] ), szLineValue );
}
}
}
case 'T':
{
switch ( szLineKey[ 12 ] )
{
case 'D':
{
switch ( szLineKey[ 16 ] )
{
case 'A':
{
if ( equal( szLineKey, "FORMAT_TEAM_DEF_ALIVE" ) )
{
copy( gszChatFormats[ formatTeamDefAlive ], charsmax( gszChatFormats[ ] ), szLineValue );
}
}
case 'D':
{
if ( equal( szLineKey, "FORMAT_TEAM_DEF_DEAD" ) )
{
copy( gszChatFormats[ formatTeamDefDead ], charsmax( gszChatFormats[ ] ), szLineValue );
}
}
}
}
case 'A':
{
if ( equal( szLineKey, "FORMAT_TEAM_Fundador_ALIVE" ) )
{
copy( gszChatFormats[ formatTeamAdminAlive ], charsmax( gszChatFormats[ ] ), szLineValue );
}
}
case 'D':
{
if ( equal( szLineKey, "FORMAT_TEAM_Fundador_DEAD" ) )
{
copy( gszChatFormats[ formatTeamAdminDead ], charsmax( gszChatFormats[ ] ), szLineValue );
}
switch ( szLineKey[ 18 ] )
{
case 'A':
{
if ( equal( szLineKey, "FORMAT_TEAM_ADMIN_ALIVE" ) )
{
copy( gszChatFormats[ formatTeamAdminAlive ], charsmax( gszChatFormats[ ] ), szLineValue );
}
}
case 'D':
{
if ( equal( szLineKey, "FORMAT_TEAM_ADMIN_DEAD" ) )
{
copy( gszChatFormats[ formatTeamAdminDead ], charsmax( gszChatFormats[ ] ), szLineValue );
}
}
}
}
case 'V':
{
switch ( szLineKey[ 16 ] )
{
case 'A':
{
if ( equal( szLineKey, "FORMAT_TEAM_VIP_ALIVE" ) )
{
copy( gszChatFormats[ formatTeamVIPAlive ], charsmax( gszChatFormats[ ] ), szLineValue );
}
}
case 'D':
{
if ( equal( szLineKey, "FORMAT_TEAM_VIP_DEAD" ) )
{
copy( gszChatFormats[ formatTeamVIPDead ], charsmax( gszChatFormats[ ] ), szLineValue );
}
}
}
}
}
}
case 'M':
{
switch ( szLineKey[ 10 ] )
{
case 'M':
{
if ( equal( szLineKey, "FORMAT_ME_MESSAGE" ) )
{
copy( gszChatFormats[ formatMeMessage ], charsmax( gszChatFormats[ ] ), szLineValue );
}
}
case 'C':
{
if ( equal( szLineKey, "FORMAT_ME_COMMAND" ) )
{
copy( gszChatFormats[ formatMeCommand ], charsmax( gszChatFormats[ ] ), szLineValue );
add( gszChatFormats[ formatMeCommand ], charsmax( gszChatFormats[ ] ), " " );
}
}
}
}
}
}
case 'C':
{
switch ( szLineKey[ 5 ] )
{
case 'C':
{
switch ( szLineKey[ 11 ] )
{
case 'R':
{
if ( equal( szLineKey, "CHAT_CLCMD_REMOVE" ) )
{
giRemoveOnSlash = str_to_num( szLineValue );
}
}
case 'C':
{
if ( equal( szLineKey, "CHAT_CLCMD_CLEAR" ) )
{
copy( gszChatFormats[ formatClearCommand ], charsmax( gszChatFormats[ ] ), szLineValue );
}
}
}
}
case 'F':
{
switch ( szLineKey[ 10 ] )
{
case 'R':
{
if ( equal( szLineKey, "CHAT_FLAG_RELOAD" ) )
{
if ( equal( szLineValue, "ALL" ) )
{
gszAccesFlags[ FLAG_RELOAD ][ 0 ] = 0;
}
else
{
copy( gszAccesFlags[ FLAG_RELOAD ], charsmax( gszAccesFlags[ ] ), szLineValue );
}
}
}
case 'S':
{
switch ( szLineKey[ 11 ] )
{
case 'P':
{
if ( equal( szLineKey, "CHAT_FLAG_SPY" ) )
{
if ( equal( szLineValue, "ALL" ) )
{
gszAccesFlags[ FLAG_SPY ][ 0 ] = 0;
}
else
{
copy( gszAccesFlags[ FLAG_SPY ], charsmax( gszAccesFlags[ ] ), szLineValue );
}
}
}
case 'E':
{
if ( equal( szLineKey, "CHAT_FLAG_SEE_CHAT" ) )
{
if ( equal( szLineValue, "ALL" ) )
{
gszAccesFlags[ FLAG_SEE_CHAT ][ 0 ] = 0;
}
else
{
copy( gszAccesFlags[ FLAG_SEE_CHAT ], charsmax( gszAccesFlags[ ] ), szLineValue );
}
}
}
}
case 'A':
{
if ( equal( szLineKey, "CHAT_FLAG_Fundador" ) )
{
if ( equal( szLineValue, "ALL" ) )
{
gszAccesFlags[ FLAG_Fundador][ 20 ] = 0;
}
else
{
copy( gszAccesFlags[ FLAG_Fundador ], charsmax( gszAccesFlags[ ] ), szLineValue );
}
}
}
}
}
case 'A':
{
if ( equal( szLineKey, "CHAT_FLAG_ADMIN" ) )
{
if ( equal( szLineValue, "ALL" ) )
{
gszAccesFlags[ FLAG_ADMIN ][ 10 ] = 0;
}
else
{
copy( gszAccesFlags[ FLAG_ADMIN ], charsmax( gszAccesFlags[ ] ), szLineValue );
}
}
}
case 'V':
{
if ( equal( szLineKey, "CHAT_FLAG_VIP" ) )
{
if ( equal( szLineValue, "ALL" ) )
{
gszAccesFlags[ FLAG_VIP ][ 0 ] = 0;
}
else
{
copy( gszAccesFlags[ FLAG_VIP ], charsmax( gszAccesFlags[ ] ), szLineValue );
}
}
}
case 'C':
{
if ( equal( szLineKey, "CHAT_FLAG_CHAT" ) )
{
if ( equal( szLineValue, "ALL" ) )
{
gszAccesFlags[ FLAG_CHAT ][ 0 ] = 0;
}
else
{
copy( gszAccesFlags[ FLAG_CHAT ], charsmax( gszAccesFlags[ ] ), szLineValue );
}
}
}
}
}
case 'A':
{
switch ( szLineKey[ 6 ] )
{
case 'D':
{
if ( equal( szLineKey, "CHAT_ADMIN_SPY" ) )
{
giAdminsSpy = str_to_num( szLineValue );
}
}
case 'L':
{
if ( equal( szLineKey, "CHAT_ALL_TALK" ) )
{
giAllTalk = str_to_num( szLineValue );
}
}
}
}
case 'D':
{
if ( equal( szLineKey, "CHAT_DEFAULT_COLOR" ) )
{
new iColor = str_to_num( szLineValue );
if ( iColor < 0 || iColor > 255255255 )
{
giUseCustomColor = 0;
}
else
{
giUseCustomColor = 1;
giRed = iColor / 1000000;
iColor %= 1000000;
giGreen = iColor / 1000;
giBlue = iColor % 1000;
}
}
}
case 'P':
{
if ( equal( szLineKey, "CHAT_PUNISHMENT" ) )
{
giPunishment = str_to_num( szLineValue );
if ( giPunishment > 1 || giPunishment < 0 )
{
giPunishment = 1;
}
}
}
case 'N':
{
if ( equal( szLineKey, "CHAT_NOTIFY" ) )
{
giUserNotify = str_to_num( szLineValue );
}
}
case 'R':
{
switch ( szLineKey[ 12 ] )
{
case 'A':
{
if ( equal( szLineKey, "CHAT_RADIUS_ALL" ) )
{
gFlPrintRadiusAll = str_to_float( szLineValue );
}
}
case 'T':
{
if ( equal( szLineKey, "CHAT_RADIUS_TEAM" ) )
{
gFlPrintRadiusTeam = str_to_float( szLineValue );
}
}
case 'C':
{
if ( equal( szLineKey, "CHAT_REMOVE_CHANGE_NAME" ) )
{
giRemoveNameChanged = str_to_num( szLineValue );
}
}
}
}
case 'T':
{
switch ( szLineKey[ 14 ] )
{
case '1':
{
switch ( szLineKey[ 16 ] )
{
case 'A':
{
if ( equal( szLineKey, "CHAT_TEAM_TAG_1_A" ) )
{
copy( gszFormatTeamTags[ T ][ ALIVE ], charsmax( gszFormatTeamTags[ ][ ] ), szLineValue );
}
}
case 'D':
{
if ( equal( szLineKey, "CHAT_TEAM_TAG_1_D" ) )
{
copy( gszFormatTeamTags[ T ][ DEAD ], charsmax( gszFormatTeamTags[ ][ ] ), szLineValue );
}
}
}
}
case '2':
{
switch ( szLineKey[ 16 ] )
{
case 'A':
{
if ( equal( szLineKey, "CHAT_TEAM_TAG_2_A" ) )
{
copy( gszFormatTeamTags[ CT ][ ALIVE ], charsmax( gszFormatTeamTags[ ][ ] ), szLineValue );
}
}
case 'D':
{
if ( equal( szLineKey, "CHAT_TEAM_TAG_2_D" ) )
{
copy( gszFormatTeamTags[ CT ][ DEAD ], charsmax( gszFormatTeamTags[ ][ ] ), szLineValue );
}
}
}
}
case '3':
{
if ( equal( szLineKey, "CHAT_TEAM_TAG_3" ) )
{
copy( gszFormatTeamTags[ SPEC ][ DEAD ], charsmax( gszFormatTeamTags[ ][ ] ), szLineValue );
}
}
}
}
case 'U':
{
switch ( szLineKey[ 16 ] )
{
case 'T':
{
if ( equal( szLineKey, "CHAT_USE_CUSTOM_TAGS" ) )
{
giUseCustomTags = str_to_num( szLineValue );
}
}
case 'F':
{
if ( equal( szLineKey, "CHAT_USE_CUSTOM_FORMATS" ) )
{
giUseCustomFormats = str_to_num( szLineValue );
}
}
}
}
}
}
}
}
fclose( iCfgFileHandle );
if ( giUseCustomFormats )
{
iChatCustomFormats( );
}
}
public iChatCustomFormats( )
{
new szIniFile[ 128 ];
get_configsdir( szIniFile, charsmax( szIniFile ) );
formatex( szIniFile, charsmax( szIniFile ), "%s/ichat_custom_formats.ini", szIniFile );
new iIniFileHandle = fopen( szIniFile, "rt" );
if ( !iIniFileHandle )
{
set_fail_state( "No custom formats file" );
return;
}
new szLineData[ 456 ], szLineKey[ 96 ], szLineKeyValue[ 96 ], szLineValue[ 264 ], iFormatType;
for ( iFormatType = 0; iFormatType < formatTypesMax; iFormatType++ )
{
TrieClear( gtCustomFormats[ iFormatType ] );
TrieClear( gtCustomFormatEnabled[ iFormatType ] );
}
while ( !feof( iIniFileHandle ) )
{
fgets( iIniFileHandle, szLineData, charsmax( szLineData ) );
trim( szLineData );
if ( szLineData[ 0 ] == ';' || szLineData[ 0 ] == '#' || ( szLineData[ 0 ] == '/' && szLineData[ 1 ] == '/' ) || !szLineData[ 0 ] )
{
continue;
}
parse( szLineData, szLineKey, charsmax( szLineKey ), szLineKeyValue, charsmax( szLineKeyValue ), szLineValue, charsmax( szLineValue ) );
if ( ( iFormatType = iChatGetFormatFromString( szLineKeyValue ) ) < 0 )
{
continue;
}
if ( ( equal( szLineKey, "STEAM_", 6 ) || equal( szLineKey, "BOT" ) ) && szLineValue[ 0 ] )
{
TrieSetString( gtCustomFormats[ iFormatType ], szLineKey, szLineValue );
TrieSetCell( gtCustomFormatEnabled[ iFormatType ], szLineKey, 1 );
}
}
fclose( iIniFileHandle );
}
public iChatGetFormatFromString( const szKey[ ] )
{
switch ( szKey[ 5 ] )
{
case 'L': return formatDefAlive;
case 'E': return formatDefDead;
case 'A': return formatTeamAlive;
case 'D': return formatTeamDead;
}
return -1;
}
public iChatHookSay( id, iTeamMessage )
{
return iChatGenerateMessage( id, iTeamMessage );
}
public iChatGenerateMessage( id, iTeamMessage )
{
if ( !is_user_connected( id ) || ( !has_flag( id, gszAccesFlags[ FLAG_CHAT ] ) && gszAccesFlags[ FLAG_CHAT ][ 0 ] ) )
{
return PLUGIN_HANDLED_MAIN;
}
new szSaid[ 128 ], iSaidLen;
iSaidLen = charsmax( szSaid );
read_args( szSaid, charsmax( szSaid ) );
remove_quotes( szSaid );
replace_all( szSaid, charsmax( szSaid ), "%s", " s" );
trim( szSaid );
if ( iChatIsChatValid( szSaid ) )
{
iChatSendToHLSW( id, szSaid, iTeamMessage );
}
if ( !contain( szSaid, gszChatFormats[ formatMeCommand ] ) )
{
iChatMeCommand( id, szSaid, iSaidLen );
return PLUGIN_HANDLED_MAIN;
}
if ( !contain( szSaid, gszChatFormats[ formatClearCommand ] ) )
{
iChatChangeChatStatus( id, IsUserChatEnabled( id ) );
return PLUGIN_HANDLED_MAIN;
}
if ( ( !szSaid[ 0 ] )
|| ( ( giRemoveOnSlash && ( szSaid[ 0 ] == '/' || szSaid[ 0 ] == '@' || szSaid[ 0 ] == '!' ) ) || ( szSaid[ 0 ] == ' ' ) )
|| ( ~IsUserChatEnabled( id ) ) )
{
return PLUGIN_HANDLED_MAIN;
}
new iAlive = is_user_alive( id );
new szMessage[ 496 ], szColor[ 16 ], szTeam[ 16 ];
get_user_team( id, szTeam, charsmax( szTeam ) );
iChatFormatMessage( id, iAlive, iTeamMessage, 0, szSaid, szMessage, charsmax( szMessage ), szColor, charsmax( szColor ) );
new iGenCheck = ( giAllTalk && !iTeamMessage );
iChatChangeTeamInfo( id, szColor, iGenCheck );
if ( iGenCheck )
{
iChatMessageAll( id, szMessage );
}
else
{
iChatMessageRest( id, iAlive, iTeamMessage, szMessage );
}
iChatChangeTeamInfo( id, szTeam, iGenCheck );
return PLUGIN_HANDLED_MAIN;
}
public iChatMeCommand( id, szSaid[ ], iSaidLen )
{
new szMessage[ 496 ], szColor[ 16 ], szTeam[ 16 ];
get_user_team( id, szTeam, charsmax( szTeam ) );
replace_all( szSaid, iSaidLen, gszChatFormats[ formatMeCommand ], " " );
trim( szSaid );
iChatFormatMessage( id, ALIVE, 0, 1, szSaid, szMessage, charsmax( szMessage ), szColor, charsmax( szColor ) );
iChatChangeTeamInfo( id, szColor, 1 );
iChatMessageAll( id, szMessage );
iChatChangeTeamInfo( id, szTeam, 1 );
}
public iChatChangeChatStatus( id, iEnabled )
{
if ( iEnabled )
{
iChatSimplePrint( id, "!g[iChat]!d %L", id, "CHAT_DISABLED" );
DisableUserChat( id );
}
else
{
EnableUserChat( id );
iChatSimplePrint( id, "!g[iChat]!d %L", id, "CHAT_ENABLED" );
}
}
public iChatFormatMessage( id, iAlive, iSayTeam, iMeCmd, const szSaid[ ], szMessage[ ], iMessageLen, szColor[ ], iColorLen )
{
new szName[ 32 ], szLife[ 16 ], iLife, iTeam;
get_user_name( id, szName, charsmax( szName ) );
iLife = get_user_health( id );
num_to_str( iLife, szLife, charsmax( szLife ) );
iTeam = get_user_team( id );
if ( iMeCmd )
{
copy( szMessage, iMessageLen, gszChatFormats[ formatMeMessage ] );
}
else
{
new iFormatType = ( iSayTeam ? ( iAlive ? formatTeamAlive : formatTeamDead ) : ( iAlive ? formatDefAlive : formatDefDead ) );
new iHasCustom = 0;
if ( giUseCustomFormats )
{
if ( TrieKeyExists( gtCustomFormatEnabled[ iFormatType ], gszAuthid[ id ] ) )
{
TrieGetCell( gtCustomFormatEnabled[ iFormatType ], gszAuthid[ id ], iHasCustom );
}
}
new iModeFormat = USER;
if ( iHasCustom )
{
iModeFormat = CUSTOM;
else if ( has_flag( id, gszAccesFlags[ FLAG_Fundador ] ) || !gszAccesFlags[ FLAG_Fundador][ 0 ] )
{
iModeFormat = Fundador;
}
else if ( has_flag( id, gszAccesFlags[ FLAG_ADMIN ] ) || !gszAccesFlags[ FLAG_ADMIN ][ 0 ] )
{
iModeFormat = ADMIN;
}
else if ( has_flag( id, gszAccesFlags[ FLAG_VIP ] ) || IsUserVip( id ) || !gszAccesFlags[ FLAG_VIP ][ 0 ] )
{
iModeFormat = VIP;
}
switch ( iModeFormat )
{
case USER:
{
switch ( iFormatType )
{
case formatTeamAlive: copy( szMessage, iMessageLen, gszChatFormats[ formatTeamDefAlive ] );
case formatTeamDead: copy( szMessage, iMessageLen, gszChatFormats[ formatTeamDefDead ] );
case formatDefAlive: copy( szMessage, iMessageLen, gszChatFormats[ formatAllDefAlive ] );
case formatDefDead: copy( szMessage, iMessageLen, gszChatFormats[ formatAllDefDead ] );
ase Fundador:
{
switch ( iFormatType )
{
case formatTeamAlive: copy( szMessage, iMessageLen, gszChatFormats[ formatTeamFundadorAlive ] );
case formatTeamDead: copy( szMessage, iMessageLen, gszChatFormats[ formatTeamFundadorDead ] );
case formatDefAlive: copy( szMessage, iMessageLen, gszChatFormats[ formatAllFundadorAlive ] );
case formatDefDead: copy( szMessage, iMessageLen, gszChatFormats[ formatAllFundadorDead ] );
}
}
}
case ADMIN:
{
switch ( iFormatType )
{
case formatTeamAlive: copy( szMessage, iMessageLen, gszChatFormats[ formatTeamAdminAlive ] );
case formatTeamDead: copy( szMessage, iMessageLen, gszChatFormats[ formatTeamAdminDead ] );
case formatDefAlive: copy( szMessage, iMessageLen, gszChatFormats[ formatAllAdminAlive ] );
case formatDefDead: copy( szMessage, iMessageLen, gszChatFormats[ formatAllAdminDead ] );
}
}
case VIP:
{
switch ( iFormatType )
{
case formatTeamAlive: copy( szMessage, iMessageLen, gszChatFormats[ formatTeamVIPAlive ] );
case formatTeamDead: copy( szMessage, iMessageLen, gszChatFormats[ formatTeamVIPDead ] );
case formatDefAlive: copy( szMessage, iMessageLen, gszChatFormats[ formatAllVIPAlive ] );
case formatDefDead: copy( szMessage, iMessageLen, gszChatFormats[ formatAllVIPDead ] );
}
}
case CUSTOM:
{
TrieGetString( gtCustomFormats[ iFormatType ], gszAuthid[ id ], szMessage, iMessageLen );
}
}
}
new szFormatTemp[ 64 ], iCustomTagsCount;
replace_all( szMessage, iMessageLen, "%TEAMTAG%", gszFormatTeamTags[ iTeam ][ iAlive ] );
if ( giUseCustomTags )
{
for ( iCustomTagsCount = 0; iCustomTagsCount < MAX_CUSTOM_TAGS; iCustomTagsCount++ )
{
formatex( szFormatTemp, charsmax( szFormatTemp ), "#CUSTOM%i#", iCustomTagsCount );
replace_all( szMessage, iMessageLen, szFormatTemp, gszCustomTags[ id ][ iCustomTagsCount ] );
}
}
replace_all( szMessage, iMessageLen, "", "^x01" );
replace_all( szMessage, iMessageLen, "", "^x04" );
if ( contain( szMessage, "" ) != -1 )
{
copy( szColor, iColorLen, "TERRORIST" );
}
else if ( contain( szMessage, "" ) != -1 )
{
copy( szColor, iColorLen, "CT" );
}
else if ( contain( szMessage, "" ) != -1 )
{
copy( szColor, iColorLen, "SPECTATOR" );
}
else
{
get_user_team( id, szFormatTemp, iColorLen );
copy( szColor, iColorLen, szFormatTemp );
}
replace_all( szMessage, iMessageLen, "", "^x03" );
replace_all( szMessage, iMessageLen, "", "^x03" );
replace_all( szMessage, iMessageLen, "", "^x03" );
replace_all( szMessage, iMessageLen, "", "^x03" );
replace_all( szMessage, iMessageLen, "%STEAMID%", gszAuthid[ id ] );
replace_all( szMessage, iMessageLen, "%LIFE%", szLife );
replace_all( szMessage, iMessageLen, "%POS%", giLocation ? gszLocation[ id ] : "" );
new szLangOpt[ 16 ];
formatex( szLangOpt, charsmax( szLangOpt ), "TEAM%i", iTeam );
formatex( szFormatTemp, charsmax( szFormatTemp ), "%L", LANG_SERVER, szLangOpt );
replace_all( szMessage, iMessageLen, "%TEAM%", szFormatTemp );
replace_all( szMessage, iMessageLen, "%NAME%", szName );
replace_all( szMessage, iMessageLen, "%MESSAGE%", szSaid );
}
public iChatMessageAll( id, const szMessage[ ] )
{
message_begin( MSG_BROADCAST, gMsgSayText );
write_byte( id );
write_string( szMessage );
message_end( );
}
public iChatMessageRest( id, iAlive, iTeamMessage, const szMessage[ ] )
{
new iTeam = get_user_team( id );
new iPlayers[ MAX_PLAYERS ], iNum, tid, iPlayerCounter, iTempAlive, iTempTeam, iTeamCheck, iRadiusCheck, iCanSeeCheck, iSupercedeCheck;
get_players( iPlayers, iNum );
for ( iPlayerCounter = 0; iPlayerCounter < iNum; iPlayerCounter++ )
{
tid = iPlayers[ iPlayerCounter ];
if ( !( iSupercedeCheck = ( id == tid ) ) )
{
iTempAlive = is_user_alive( tid );
if ( iTeamMessage )
{
iTempTeam = get_user_team( tid );
}
iTeamCheck = ( !iTeamMessage || ( iTeam == iTempTeam ) );
iRadiusCheck = iChatIsInRadius( id, tid, iTeamMessage, iAlive, iTempAlive );
iCanSeeCheck = ( ( has_flag( tid, gszAccesFlags[ FLAG_SEE_CHAT ] ) || !gszAccesFlags[ FLAG_SEE_CHAT ][ 0 ] ) && IsUserChatEnabled( tid ) );
}
if ( ( iSupercedeCheck )
|| ( ( ( ( giAllTalk || ( iAlive && iTempAlive ) ) || ( !iAlive && !iTempAlive ) ) && iTeamCheck && iRadiusCheck && iCanSeeCheck )
|| ( giAdminsSpy && ( has_flag( tid, gszAccesFlags[ FLAG_SPY ] ) || !gszAccesFlags[ FLAG_SPY ][ 0 ] ) )
|| ( is_user_hltv( tid ) ) ) )
{
message_begin( MSG_ONE, gMsgSayText, .player = tid );
write_byte( id );
write_string( szMessage );
message_end( );
}
}
}
public iChatIsInRadius( iSender, iReceiver, iTeamMessage, iSenderAlive, iReceiverAlive )
{
new Float:flSenderOrigin[ 3 ], Float:flRecieverOrigin[ 3 ], Float:flDistance, Float:flMaxRadius;
pev( iSender, pev_origin, flSenderOrigin );
pev( iReceiver, pev_origin, flRecieverOrigin );
flDistance = get_distance_f( flSenderOrigin, flRecieverOrigin );
if ( iTeamMessage )
{
flMaxRadius = gFlPrintRadiusTeam;
}
else
{
flMaxRadius = gFlPrintRadiusAll;
}
if ( flDistance <= flMaxRadius || flMaxRadius <= 0 || !iSenderAlive || !iReceiverAlive )
{
return 1;
}
return 0;
}
public iChatEventLocation( id )
{
giLocation = 1;
if ( read_data( 1 ) == id )
{
read_data( 2, gszLocation[ id ], charsmax( gszLocation[ ] ) );
}
}
public client_putinserver( id )
{
if ( giUserNotify )
{
set_task( NOTIFY_TASK_TIME, "iChatNotify", id + TASK_NOTIFY );
}
get_user_authid( id, gszAuthid[ id ], charsmax( gszAuthid[ ] ) );
SetUserFirstSpawn( id );
EnableUserChat( id );
}
public plugin_end( )
{
new iFormatType;
for ( iFormatType = 0; iFormatType < formatTypesMax; iFormatType++ )
{
TrieDestroy( gtCustomFormats[ iFormatType ] );
TrieDestroy( gtCustomFormatEnabled[ iFormatType ] );
}
}
public iChatPlayerSpawn( id )
{
if ( giUseCustomColor && is_user_connected( id ) && !is_user_bot( id ) && IsFirstSpawn( id ) )
{
iChatAskChangeCvar( id );
}
ClearUserFirstSpawn( id );
}
public iChatAskChangeCvar( id )
{
new szMenuFormat[ 164 ], iLen = charsmax( szMenuFormat );
formatex( szMenuFormat, iLen, "%L", id, "MENU_TITLE", giRed, giGreen, giBlue );
new iAskMenu = menu_create( szMenuFormat, "iChatAskMenuHandler" );
new szMenuAction[ 16 ];
formatex( szMenuAction, charsmax( szMenuAction ), "MENU_ACTION%i", giPunishment );
formatex( szMenuFormat, iLen, "%L %L", id, "MENU_NO", id, szMenuAction );
menu_additem( iAskMenu, szMenuFormat );
formatex( szMenuFormat, iLen, "%L", id, "MENU_YES" );
menu_additem( iAskMenu, szMenuFormat );
menu_setprop( iAskMenu, MPROP_EXIT, MEXIT_NEVER );
menu_display( id, iAskMenu );
}
public iChatAskMenuHandler( id, iMenu, iItem )
{
if ( iItem == 1 )
{
client_cmd( id, "con_color ^"%i %i %i^"", giRed, giGreen, giBlue );
}
else if ( giPunishment )
{
server_cmd( "kick #%d ^"%L^"", get_user_userid( id ), id, "KICK_REASON" );
}
menu_destroy( iMenu );
}
public iChatIsChatValid( const szChat[ ] )
{
new cChar, iCharCounter;
while ( ( cChar = szChat[ iCharCounter++ ] ) != EOS )
{
if ( cChar != ' ' )
{
return 1;
}
}
return 0;
}
public iChatSendToHLSW( id, const szSaid[ ], iTeamMessage )
{
new szName[ 32 ], szTeam[ 10 ];
get_user_name( id, szName, charsmax( szName ) );
get_user_team( id, szTeam, charsmax( szTeam ) );
if( szTeam[ 0 ] == 'U' )
{
szTeam[ 0 ] = EOS;
}
log_message( "^"%s<%d><%s><%s>^" %s ^"%s^"%s", szName, get_user_userid( id ), gszAuthid[ id ], szTeam, ( iTeamMessage ? "say_team" : "say" ), szSaid, is_user_alive( id ) ? "" : " (dead)" );
}
public iChatChangeTeamInfo( id, const szColor[ ], iToAll )
{
message_begin( iToAll ? MSG_BROADCAST : MSG_ONE, gMsgTeamInfo, .player = id );
write_byte( id );
write_string( szColor );
message_end( );
}
public iChatMessageSayText( iMsgId, iMsgDest, iMsgEntity )
{
if ( giRemoveNameChanged )
{
new szMessage[ 196 ];
get_msg_arg_string( 2, szMessage, charsmax( szMessage ) );
if ( equal( szMessage, "#Cstrike_Name_Change" ) )
{
return PLUGIN_HANDLED;
}
}
return PLUGIN_CONTINUE;
}
public iChatNotify( id )
{
id -= TASK_NOTIFY;
iChatSimplePrint( id, "!g[iChat]!d This server is using !tiChat!d by !tWanderson1312!d. Download link in your console." );
client_print( id, print_console, "[iChat] Download 'iChat' by Wanderson at 'https://forums.alliedmods.net/showthread.php?t=173113'." );
client_print( id, print_console, "[iChat] Or on GitHub at 'https://github.com/Kid-/iChat'" );
}
public iChatSimplePrint( id, const szMessage[ ], any:... )
{
new szBuffer[ 512 ];
vformat( szBuffer, charsmax( szBuffer ), szMessage, 3 );
replace_all( szBuffer, charsmax( szBuffer ), "!d", "^x01" );
replace_all( szBuffer, charsmax( szBuffer ), "!t", "^x03" );
replace_all( szBuffer, charsmax( szBuffer ), "!g", "^x04" );
message_begin( MSG_ONE, gMsgSayText, .player = id );
write_byte( id );
write_string( szBuffer );
message_end( );
}
public iChatSendCustomData( iPlugin, iParams )
{
new iTagIndex = get_param( 2 );
new szData[ MAX_CUSTOM_TAGS_SIZE ];
get_string( 3, szData, charsmax( szData ) );
copy( gszCustomTags[ get_param( 1 ) ][ ( ( iTagIndex < 0 || iTagIndex >= MAX_CUSTOM_TAGS ) ? 0 : iTagIndex ) ], charsmax( gszCustomTags[ ][ ] ), szData );
}
public iChatVipAction( iPlugin, iParams )
{
new id = get_param( 1 );
switch ( get_param( 2 ) )
{
case 0: return IsUserVip( id );
case 1: return SetUserVip( id );
case 2: return ClearUserVip( id );
}
return -1;
}
[code]
Não se preucupe nao tem master e so pra testes