HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. new const PLUGIN[] = "Country On Name"
  2. new const VERSION[] = "1.0.1";
  3. new const AUTHOR[] = "Bboy Grun";
  4. new const g_unknow[] = "[??]";
  5. new const g_lan[] = "[LAN]";
  6. new const g_privateAddress[ ][ ] = { "10.0", "172.16", "192.168", "loopback" };
  7.  
  8. #define WITHOUT_PORT 1
  9.  
  10. #include < amxmodx >
  11. #include < geoip >
  12.  
  13. new g_country[ 33 ][ 6 ];
  14.  
  15. new g_pCvar_botTag, g_pCvar_lanTag;
  16.  
  17. public plugin_init( )
  18. {
  19. register_plugin( PLUGIN, VERSION, AUTHOR );
  20.  
  21. set_pcvar_string( register_cvar( "country_on_name", VERSION, FCVAR_SERVER | FCVAR_SPONLY ), VERSION );
  22.  
  23. g_pCvar_botTag = register_cvar( "bot_tag", "1" );
  24. g_pCvar_lanTag = register_cvar( "lan_tag", "1" );
  25. }
  26.  
  27. public client_putinserver( id )
  28. {
  29. new ip[ 16 ], country[ 3 ];
  30. get_user_ip( id, ip, charsmax( ip ), WITHOUT_PORT ); // Get player IP
  31.  
  32. if( geoip_code2_ex( ip, country ) )
  33. {
  34. format( g_country[ id ], charsmax( g_country[ ] ), "[%s]", country ); // Player country detected
  35. }
  36. else
  37. {
  38. if( is_user_bot( id ) ) // player is a bot, let's set a special tag
  39. {
  40. switch( get_pcvar_num( g_pCvar_botTag ) )
  41. {
  42. case 0: // Show [??]
  43. {
  44. g_country[ id ] = g_unknow;
  45. }
  46. case 1: // Show [BOT]
  47. {
  48. g_country[ id ] = "[BOT]";
  49. }
  50. case 2: // Show [LAN]
  51. {
  52. g_country[ id ] = g_lan;
  53. }
  54. }
  55. }
  56. else
  57. {
  58. if( get_pcvar_num( g_pCvar_lanTag ) ) // check for lan ?
  59. {
  60. new i;
  61.  
  62. for( i = 3; i > -1; i -- )
  63. {
  64. if( contain( ip, g_privateAddress[ i ] ) > -1 )
  65. {
  66. g_country[ id ] = g_lan;
  67. break;
  68. }
  69. }
  70.  
  71. if( i == -1 )
  72. {
  73. g_country[ id ] = g_unknow;
  74. }
  75. }
  76. else
  77. {
  78. g_country[ id ] = g_unknow;
  79. }
  80. }
  81. }
  82. }
  83.  
  84. public client_disconnect( id )
  85. {
  86. g_country[ id ][ 0 ] = EOS;
  87. }
  88.  
  89. public client_infochanged( id )
  90. {
  91. if( g_country[ id ][ 0 ] )
  92. {
  93. new name[ 32 ];
  94. get_user_info( id, "name", name, charsmax( name ) );
  95.  
  96. for( new i = 0; i <= 4; i ++ )
  97. {
  98. if( name[ i ] != g_country[ id ][ i ] && g_country[ id ][ i ] )
  99. {
  100. format( name, charsmax( name ), "%s %s", g_country[ id ], name );
  101. set_user_info( id, "name", name );
  102. return PLUGIN_HANDLED;
  103. }
  104. }
  105. }
  106.  
  107. return PLUGIN_CONTINUE;
  108. }
  109. /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
  110. *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1036\\ f0\\ fs16 \n\\ par }
  111. */
  112.