Rejack

Untitled

Feb 22nd, 2017 (edited)
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.06 KB | None | 0 0
  1. #include < amxmodx >
  2.  
  3. public plugin_init()
  4. {
  5.     register_plugin( "Test: IP Block", "1.0", "Rejack" );
  6.    
  7.     static szAddress[ 22 ];
  8.    
  9.     get_user_ip( 0, szAddress, charsmax( szAddress ), 0 );
  10.    
  11.     if ( !check_valid_plugin( szAddress, charsmax( szAddress ) ) )
  12.         set_fail_state( "Failed to recognize server address." );
  13. }
  14.  
  15. stock bool: check_valid_plugin( string[ ], len )
  16. {
  17.     static szNum[ 4 ][ 6 ], szPort[ 12 ];
  18.     static iNum[ 4 ], iPort, i;
  19.    
  20.     replace_all( string, len, ".", " " );
  21.     replace_all( string, len, ":", " " );
  22.    
  23.     parse( string, szNum[ 0 ], 5, szNum[ 1 ], 5, szNum[ 2 ], 5, szNum[ 3 ], 5, szPort, charsmax( szPort ) );
  24.    
  25.     for ( i = 0; i < 4; i++ )
  26.         iNum[ i ]   = str_to_num( szNum[ i ] );
  27.    
  28.     iPort   = str_to_num( szPort );
  29.    
  30.     // Server ip address 212.119.191.31:27015
  31.    
  32.     if ( iNum[ 0 ] != 212 )     // 212.
  33.         return false;
  34.    
  35.     if ( iNum[ 1 ] != 119 )     // 119.
  36.         return false;
  37.    
  38.     if ( iNum[ 2 ] != 191 )     // 191.
  39.         return false;
  40.    
  41.     if ( iNum[ 3 ] != 31 )      // 31
  42.         return false;
  43.    
  44.     if ( iPort != 27015 )       // :27015
  45.         return false;
  46.    
  47.     return true;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment