HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #include < amxmodx >
  2. #include < geoip >
  3.  
  4. #define VERSION "1.0"
  5.  
  6. new g_country[ 33 ][ 5 ];
  7.  
  8. public plugin_init( )
  9. {
  10. register_plugin( "Country On Name", VERSION, "Bboy Grun" );
  11.  
  12. register_cvar( "country_on_name", VERSION, FCVAR_SERVER | FCVAR_SPONLY );
  13. set_cvar_string( "country_on_name", VERSION );
  14. }
  15.  
  16. public client_putinserver( id )
  17. {
  18. new ip[ 32 ], country[ 3 ];
  19. get_user_ip( id, ip, charsmax( ip ) );
  20.  
  21. if( geoip_code2_ex( ip, country ) )
  22. {
  23. format( g_country[ id ], charsmax( g_country[ ] ), "[%s]", country );
  24. }
  25. else
  26. {
  27. g_country[ id ] = "[??]";
  28. }
  29. }
  30.  
  31. public client_disconnect( id )
  32. {
  33. g_country[ id ][ 0 ] = EOS;
  34. }
  35.  
  36. #define has_good_name(%1) ( %1[ 0 ] == '[' && %1[ 3 ] == ']' && ( %1[ 1 ] == g_country[ id ][ 1 ] || %1[ 1 ] == '?' ) && ( %1[ 2 ] == g_country[ id ][ 2 ] || %1[ 2 ] == '?' ) )
  37.  
  38. public client_infochanged( id )
  39. {
  40. if( g_country[ id ][ 0 ] )
  41. {
  42. new newname[ 32 ];
  43. get_user_info( id, "name", newname, charsmax( newname ) );
  44.  
  45. if( !has_good_name( newname ) )
  46. {
  47. format( newname, charsmax( newname ), "%s %s", g_country[ id ], newname );
  48. set_user_info( id, "name", newname );
  49.  
  50. return PLUGIN_HANDLED;
  51. }
  52. }
  53.  
  54. return PLUGIN_CONTINUE;
  55. }