קוד:
#include < amxmodx >#include < cstrike >
#define TRANSLATE_ACCESS ADMIN_CVAR
#define g_mPrefix "Translate"
#define g_mTask 1213
enum _:g_mTranslateData
{
m_mEnglishWord[ 30 ],
m_mHebrewWord[ 30 ]
};
new Array:g_aQuestions;
new g_szFile[ 64 ], g_iQuestion[ g_mTranslateData ], g_iCountdown, bool:g_bActive, bool:g_bWrite;
public plugin_init( )
{
register_plugin( "Jailbreak Translate", "v1.0", "xControl" );
register_clcmd( "say", "CmdHandleSay" );
register_clcmd( "say /ts", "CmdStartTranslate" );
register_clcmd( "say /stopts", "CmdStopTranslate" );
CmdLoadQuestions( );
}
public CmdHandleSay( client )
{
if ( ! is_user_connected( client ) ) return 1;
if ( ! g_bWrite ) return 0;
new szArgs[ 192 ];
read_argv( 1, szArgs, charsmax( szArgs ) );
if ( equali( szArgs, g_iQuestion[ m_mEnglishWord ] ) )
{
new szName[ 32 ];
get_user_name( client, szName, charsmax( szName ) );
set_hudmessage( 0, 85, 255, -1.0, 0.10, 1, 6.0, 5.0 );
show_hudmessage( 0, "%s Won In The Translate Contest !", szName );
g_bActive = false;
g_bWrite = false;
return 1;
}
return 0;
}
public CmdStartTranslate( client )
{
if ( ! is_user_connected( client ) ) return 1;
if ( cs_get_user_team( client ) != CS_TEAM_T && ! access( client, TRANSLATE_ACCESS ) ) return client_print( client, print_chat, "[%s] You have no access to this command.", g_mPrefix );
if ( ! is_user_alive( client ) ) return client_print( client, print_chat, "[%s] You must to be alive to use this command.", g_mPrefix );
if ( g_bActive ) return client_print( client, print_chat, "[%s] The translate contest is alredy activated.", g_mPrefix );
new szName[ 32 ];
get_user_name( client, szName, charsmax( szName ) );
client_print( 0, print_chat, "[%s] %s has started a translate contest !", g_mPrefix, szName );
g_iCountdown = 5;
set_task( 1.0, "CmdCountdown", g_mTask, _, _, "b" );
g_bActive = true;
return 1;
}
public CmdCountdown( task )
{
if ( g_iCountdown > 0 )
{
new szVox[ 32 ];
num_to_word( g_iCountdown, szVox, charsmax( szVox ) );
client_cmd( 0, "spk ^"vox/%s^"", szVox );
set_hudmessage( 0, 85, 255, -1.0, 0.10, 1, 6.0, 5.0 );
show_hudmessage( 0, "The Translate Contest Will Start In %i Seconds", g_iCountdown );
}
else
{
ArrayGetArray( g_aQuestions, random( ArraySize( g_aQuestions ) ), g_iQuestion );
remove_task( task );
set_hudmessage( 0, 85, 255, -1.0, 0.10, 1, 6.0, 5.0 );
show_hudmessage( 0, "The First Will Translate The Word:^n%s^nWill Won The Translate Contest", g_iQuestion[ m_mHebrewWord ] );
g_bWrite = true;
}
g_iCountdown -= 1;
}
public CmdStopTranslate( client )
{
if ( ! is_user_connected( client ) ) return 1;
if ( cs_get_user_team( client ) != CS_TEAM_T && ! access( client, TRANSLATE_ACCESS ) ) return client_print( client, print_chat, "[%s] You have no access to this command.", g_mPrefix );
if ( ! is_user_alive( client ) ) return client_print( client, print_chat, "[%s] You must to be alive to use this command.", g_mPrefix );
if ( ! g_bActive ) return client_print( client, print_chat, "[%s] There is no translate contest activated.", g_mPrefix );
if ( task_exists( g_mTask ) ) remove_task( g_mTask );
g_bActive = false;
g_bWrite = false;
new szName[ 32 ];
get_user_name( client, szName, charsmax( szName ) );
client_print( 0, print_chat, "[%s] %s has stopped the translate contest.", g_mPrefix, szName );
return 1;
}
stock CmdLoadQuestions( )
{
get_configsdir( g_szFile, charsmax( g_szFile ) );
format( g_szFile, charsmax( g_szFile ), "%s/Translate.cfg", g_szFile );
if ( ! file_exists( g_szFile ) )
{
write_file( g_szFile, "^"Blue^"כחול^"" );
write_file( g_szFile, "^"Computer^" ^"מחשב^"" );
write_file( g_szFile, "; ^"TV^" ^"טלוויזיה^"" );
write_file( g_szFile, "^"Yellow^" ^"צהוב^"" );
write_file( g_szFile, "^"Football^" ^"כדורגל^"" );
write_file( g_szFile, "^"Table^" ^"שולחן^"" );
write_file( g_szFile, "^"Chair^" ^"כסא^"" );
write_file( g_szFile, "^"Red^" ^"אדום^"" );
}
g_aQuestions = ArrayCreate( g_mTranslateData );
static g_iQuestions[ g_mTranslateData ];
static iFile;
iFile = fopen( g_szFile, "rt" );
static szBuffer[ 70 ];
while ( ! feof( iFile ) )
{
fgets( iFile, szBuffer, charsmax( szBuffer ) );
trim( szBuffer );
if ( szBuffer[ 0 ] == ';' || equali( szBuffer, "//", 2 ) || strlen( szBuffer ) < 3 ) continue;
parse( szBuffer, g_iQuestions[ m_mEnglishWord ], charsmax( g_iQuestions[ m_mEnglishWord ] ), g_iQuestions[ m_mHebrewWord ], charsmax( g_iQuestions[ m_mHebrewWord ] ) );
remove_quotes( g_iQuestions[ m_mEnglishWord ] );
remove_quotes( g_iQuestions[ m_mHebrewWord ] );
ArrayPushArray( g_aQuestions, g_iQuestions );
}
log_amx( "Successfuly loaded %i translate questions.", ArraySize( g_aQuestions ) );
return 1;
}
stock access( const index, const flag )
{
return ( get_user_flags( index ) & flag );
}
stock get_configsdir( name[ ], len )
{
return get_localinfo( "amxx_configsdir", name, len );
}