Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include < amxmodx >
- public plugin_init()
- {
- register_plugin( "Test: IP Block", "1.0", "Rejack" );
- static szAddress[ 22 ];
- get_user_ip( 0, szAddress, charsmax( szAddress ), 0 );
- if ( !check_valid_plugin( szAddress, charsmax( szAddress ) ) )
- set_fail_state( "Failed to recognize server address." );
- }
- stock bool: check_valid_plugin( string[ ], len )
- {
- static szNum[ 4 ][ 6 ], szPort[ 12 ];
- static iNum[ 4 ], iPort, i;
- replace_all( string, len, ".", " " );
- replace_all( string, len, ":", " " );
- parse( string, szNum[ 0 ], 5, szNum[ 1 ], 5, szNum[ 2 ], 5, szNum[ 3 ], 5, szPort, charsmax( szPort ) );
- for ( i = 0; i < 4; i++ )
- iNum[ i ] = str_to_num( szNum[ i ] );
- iPort = str_to_num( szPort );
- // Server ip address 212.119.191.31:27015
- if ( iNum[ 0 ] != 212 ) // 212.
- return false;
- if ( iNum[ 1 ] != 119 ) // 119.
- return false;
- if ( iNum[ 2 ] != 191 ) // 191.
- return false;
- if ( iNum[ 3 ] != 31 ) // 31
- return false;
- if ( iPort != 27015 ) // :27015
- return false;
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment