Veteran Member
Join Date: Aug 2015
Location: Dreams, zz
|
01-25-2016
, 10:44
Re: It should work?
|
#20
|
Quote:
Originally Posted by Giass
Hello!
I got this code:
Now i want the message be written like: asd --> dsa
I want it only if its on Hebrew mod.
Thanks!
|
It is done, I attached it.
PHP Code:
#include <amxmodx>
#include <amxmisc>
#pragma semicolon 1
#define COLOR_MESSAGE 192
#define LONG_STRING 256
/** This is to view internal program data while execution. See the function 'debugMesssageLogger(...)'
* and the variable 'g_debug_level' for more information. Default value: 0 - which is disabled.
*/
#define IS_DEBUG_ENABLED 0
#if IS_DEBUG_ENABLED > 0
#define DEBUG_LOGGER(%1) debugMesssageLogger( %1 );
/**
* ( 0 ) 0 disabled all debug.
* ( 1 ) 1 displays basic debug messages.
*/
new g_debug_level = 1;
/**
* Write debug messages to server's console accordantly to the global variable g_debug_level.
*
* @param mode the debug mode level, see the variable 'g_debug_level' for the levels.
* @param message[] the text formatting rules to display.
* @param any the variable number of formatting parameters.
*/
stock debugMesssageLogger( mode, message[], any: ... )
{
if( mode & g_debug_level )
{
static g_said[ LONG_STRING ];
vformat( g_said, charsmax( g_said ), message, 3 );
server_print( "%s", g_said );
client_print( 0, print_chat, "%s", g_said );
}
}
#else
#define DEBUG_LOGGER(%1) //
#endif
#if AMXX_VERSION_NUM < 183
new g_user_msgid;
#endif
new bool:g_is_color_chat_supported;
#define PRINT_COLORED_MESSAGE(%1,%2) \
{ \
message_begin( MSG_ONE_UNRELIABLE, g_user_msgid, _, %1 ); \
write_byte( %1 ); \
write_string( %2 ); \
message_end(); \
}
#define REMOVE_COLOR_TAGS(%1) \
{ \
replace_all( %1, charsmax( %1 ), "^1", "" ); \
replace_all( %1, charsmax( %1 ), "^2", "" ); \
replace_all( %1, charsmax( %1 ), "^3", "" ); \
replace_all( %1, charsmax( %1 ), "^4", "" ); \
}
new bool:Shalom[33];
new g_said[COLOR_MESSAGE];
public plugin_init()
{
register_plugin("Hebrew chat", "2.0.1", "TimeBomb/Addons zz");
register_clcmd("say", "SayHook", 0);
register_clcmd("say_team", "SayHook", 1);
}
public client_putinserver(client)
{
Shalom[client] = false;
}
public plugin_cfg()
{
#if AMXX_VERSION_NUM < 183
g_user_msgid = get_user_msgid( "SayText" );
#endif
g_is_color_chat_supported = ( is_running( "czero" )
|| is_running( "cstrike" ) );
}
public SayHook(client, team)
{
read_args(g_said, charsmax(g_said));
remove_quotes(g_said);
if( !isalnum(g_said[0]) )
{
if( equali(g_said[1], "heb", 3) )
{
client_print(client, print_chat, "[HEBREW] From now you talk %s, to switch back \
type /heb (also !heb) again.", (Shalom[client] = !Shalom[client]) ? "Hebrew": "English");
return PLUGIN_HANDLED;
}
}
if( Shalom[client] )
{
static reverse[COLOR_MESSAGE];
static user_name[32];
static team_name[32];
static players_in_range[32];
static index;
static classmate;
static players_number;
get_user_name( client, user_name, charsmax( user_name ) );
classmate = strlen( g_said ); // caches the string length
for( index = 0; index < classmate; index++ )
{
reverse[index] = g_said[ classmate - index - 1 ];
}
reverse[index] = '^0';
DEBUG_LOGGER( 1, "User: %s, Team: %d, Shalom[client]: %d, Said: %s", \
user_name, team, Shalom[client], reverse )
translate_symbols( reverse, charsmax( reverse ) );
get_players( players_in_range, players_number, "c" );
if( team )
{
for( index = 0; index < players_number; index++ )
{
classmate = players_in_range[ index ];
if( get_user_team( client ) == get_user_team( classmate, team_name, charsmax( team_name ) ) )
{
client_print_color_internal( classmate, "^2(%s) %s:^1%s", team_name, user_name, reverse );
}
}
}
else
{
for( index = 0; index < players_number; index++ )
{
classmate = players_in_range[ index ];
client_print_color_internal( classmate, "^2%s:^1%s", user_name, reverse );
}
}
return PLUGIN_HANDLED;
}
return PLUGIN_CONTINUE;
}
stock translate_symbols( reverse[], size )
{
replace_all(reverse, size, "q", "/");
replace_all(reverse, size, "w", "'");
replace_all(reverse, size, "e", "ק");
replace_all(reverse, size, "r", "ר");
replace_all(reverse, size, "t", "א");
replace_all(reverse, size, "y", "ט");
replace_all(reverse, size, "u", "ו");
replace_all(reverse, size, "i", "ן");
replace_all(reverse, size, "o", "ם");
replace_all(reverse, size, "p", "פ");
replace_all(reverse, size, "a", "ש");
replace_all(reverse, size, "s", "ד");
replace_all(reverse, size, "d", "ג");
replace_all(reverse, size, "f", "כ");
replace_all(reverse, size, "g", "ע");
replace_all(reverse, size, "h", "י");
replace_all(reverse, size, "j", "ח");
replace_all(reverse, size, "k", "ל");
replace_all(reverse, size, "l", "ך");
replace_all(reverse, size, ";", "ף");
replace_all(reverse, size, "'", ",");
replace_all(reverse, size, "z", "ז");
replace_all(reverse, size, "x", "ס");
replace_all(reverse, size, "c", "ב");
replace_all(reverse, size, "v", "ה");
replace_all(reverse, size, "b", "נ");
replace_all(reverse, size, "n", "מ");
replace_all(reverse, size, "m", "צ");
replace_all(reverse, size, ",", "ת");
replace_all(reverse, size, ".", "ץ");
replace_all(reverse, size, "/", ".");
}
stock client_print_color_internal( player_id, message[], any: ... )
{
g_said[0] = '^0';
vformat( g_said, charsmax( g_said ), message, 3 );
if( g_is_color_chat_supported )
{
#if AMXX_VERSION_NUM < 183
PRINT_COLORED_MESSAGE( player_id, g_said )
#else
client_print_color( player_id, print_team_default, g_said );
#endif
}
else
{
REMOVE_COLOR_TAGS( g_said )
client_print( player_id, print_chat, g_said );
}
}
__________________
|
|