Raised This Month: $ Target: $400
 0% 

CityConnectAnnouncer


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
XphaN
Member
Join Date: Mar 2009
Old 02-07-2010 , 20:01   CityConnectAnnouncer
Reply With Quote #1

What I have to edit to show me the IP of connecting player? Thanks.

Code:
#include <amxmodx>
#include <amxmisc>
#include <geoipse>
#include <geoip>
#include <colorchat>

// http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz

new Float:gflLongitude[33];
new Float:gflLatitude[33];
new bool:gIsUserConnected[33];
new gMaxplayers;

public plugin_init() {
	register_plugin( "City Connect Announcer", "1.0", "xPaw" );
	
	gMaxplayers = get_maxplayers( );
}

public client_putinserver( id ) {
	gIsUserConnected[id] = true;
	
	if( is_user_bot( id ) ) {
		gIsUserConnected[id] = false;	// lets make less loops in distance counting xD
		
		return PLUGIN_CONTINUE;
	}
	
	new szIP[32], szCountry[46], szCity[46], szName[32];
	get_user_name(id, szName, 31);
	get_user_ip( id, szIP, 31, 1 );
	
	if( equal( szIP, "loopback" ) )
		format( szIP, sizeof( szIP ) - 1, "85.196.220.208" ) // o hai i am hardcoder.
	
	geoip_country( szIP, szCountry );
	geoip_city( szIP, szCity );
	
	gflLatitude[id] = geoip_latitude( szIP );
	gflLongitude[id] = geoip_longitude( szIP );
	
	if( equal(szCountry, "error") ) {
		if( !contain(szIP, "192.168.") || !contain(szIP, "10. ") || !contain(szIP, "172.") || equal(szIP, "127.0.0.1") )
			szCountry = "LAN";
		
		else if( equal(szIP, "loopback") )
			szCountry = "LAN Owner";
		
		else
			szCountry = "Unknown Country";
	}
	
	if( get_user_flags(id) & ADMIN_KICK ) {
		if( !equal( szCity, "error" ) )
			ColorChat( 0, BLUE, "^x01* Admin^x04 %s^x01 has connected from^x03 %s^x01,^x03 %s^x01.", szName, szCity, szCountry );
		else
			ColorChat( 0, BLUE, "^x01* Admin^x04 %s^x01 has connected from^x03 %s^x01.", szName, szCountry );
	} else {
		if( !equal( szCity, "error" ) )
			ColorChat( 0, BLUE, "^x01*^x04 %s^x01 has connected from^x03 %s^x01,^x03 %s^x01.", szName, szCity, szCountry );
		else
			ColorChat( 0, BLUE, "^x01*^x04 %s^x01 has connected from^x03 %s^x01.", szName, szCountry );
	}
	
	if( gflLongitude[id] != 0.0 && gflLatitude[id] != 0.0 )
		set_task( 0.2, "PrintDistance", id ); // gay fix.
	
	return PLUGIN_CONTINUE;
}

public PrintDistance( id ) {
	static i, szName[ 32 ];
	get_user_name( id, szName, 31 );
	
	for( i = 1; i <= gMaxplayers; i++ )
		if( gIsUserConnected[i] && id != i )
			if( gflLongitude[i] != 0.0 && gflLatitude[i] != 0.0 )
				ColorChat( i, RED, "^x01*^x04 %s^x01 is about^x03 %d^x01 kilometers far away from you.", szName, floatround( geoip_distance( gflLatitude[id], gflLatitude[i], gflLongitude[id], gflLongitude[i] ) ) );
}

public client_disconnect( id ) {
	gIsUserConnected[id] = false;
	
	if( is_user_bot( id ) )
		return PLUGIN_CONTINUE;
	
	new szIP[32], szCountry[46], szCity[46], szName[32];
	get_user_name(id, szName, 31);
	get_user_ip( id, szIP, 31, 1 );
	geoip_country( szIP, szCountry );
	geoip_city( szIP, szCity );
	
	if( equal(szCountry, "error") ) {
		if( !contain(szIP, "192.168.") || !contain(szIP, "10. ") || !contain(szIP, "172.") || equal(szIP, "127.0.0.1") )
			szCountry = "LAN";
		
		else if( equal(szIP, "loopback") )
			szCountry = "LAN Owner";
		
		else
			szCountry = "Unknown Country";
	}
	
	if( get_user_flags(id) & ADMIN_KICK ) {
		if( !equal( szCity, "error" ) )
			ColorChat( 0, BLUE, "^x01* Admin^x04 %s^x01 has disconnected from^x03 %s^x01,^x03 %s^x01.", szName, szCity, szCountry );
		else
			ColorChat( 0, BLUE, "^x01* Admin^x04 %s^x01 has disconnected from^x03 %s^x01.", szName, szCountry );
	} else {
		if( !equal( szCity, "error" ) )
			ColorChat( 0, BLUE, "^x01*^x04 %s^x01 has disconnected from^x03 %s^x01,^x03 %s^x01.", szName, szCity, szCountry );
		else
			ColorChat( 0, BLUE, "^x01*^x04 %s^x01 has disconnected from^x03 %s^x01.", szName, szCountry );
	}
	
	return PLUGIN_CONTINUE;
}

stock Float:geoip_distance( Float:flLat1, Float:flLat2, Float:flLon1, Float:flLon2 )
	return ( 6371.0 * floatacos( floatsin( flLat1 / 57.3 ) * floatsin( flLat2 / 57.3 ) + floatcos( flLat1 / 57.3 ) * floatcos( flLat2 / 57.3 ) * floatcos( flLon2 / 57.3 - flLon1 / 57.3 ), 0 ) )
__________________
XphaN is offline
Send a message via Yahoo to XphaN
Seta00
The Seta00 user has crashed.
Join Date: Jan 2010
Location: Berlin
Old 02-08-2010 , 07:09   Re: CityConnectAnnouncer
Reply With Quote #2

Quote:
Originally Posted by XphaN View Post
What I have to edit to show me the IP of connecting player? Thanks.
Here:
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <geoipse>
#include <geoip>
#include <colorchat>

// http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz

new Float:gflLongitude[33];
new 
Float:gflLatitude[33];
new 
bool:gIsUserConnected[33];
new 
gMaxplayers;

public 
plugin_init() {
    
register_plugin"City Connect Announcer""1.0""xPaw" );
    
    
gMaxplayers get_maxplayers( );
}

public 
client_putinserverid ) {
    
gIsUserConnected[id] = true;
    
    if( 
is_user_botid ) ) {
        
gIsUserConnected[id] = false;    // lets make less loops in distance counting xD
        
        
return PLUGIN_CONTINUE;
    }
    
    new 
szIP[32], szCountry[46], szCity[46], szName[32];
    
get_user_name(idszName31);
    
get_user_ipidszIP31);
        
    
geoip_countryszIPszCountry );
    
geoip_cityszIPszCity );
    
    
gflLatitude[id] = geoip_latitudeszIP );
    
gflLongitude[id] = geoip_longitudeszIP );
    
    if( 
equal(szCountry"error") ) {
        if( !
contain(szIP"192.168.") || !contain(szIP"10. ") || !contain(szIP"172.") || equal(szIP"127.0.0.1") )
            
szCountry "LAN";
        
        else if( 
equal(szIP"loopback") )
            
szCountry "LAN Owner";
        
        else
            
szCountry "Unknown Country";
    }
    
    
// modifications:
    
if( get_user_flags(id) & ADMIN_KICK ) {
        if( !
equalszCity"error" ) )
            
ColorChat0BLUE"^x01* Admin^x04 %s^x01 (%s) has connected from^x03 %s^x01,^x03 %s^x01."szNameszIPszCityszCountry );
        else
            
ColorChat0BLUE"^x01* Admin^x04 %s^x01 (%s) has connected from^x03 %s^x01."szNameszIPszCountry );
    } else {
        if( !
equalszCity"error" ) )
            
ColorChat0BLUE"^x01*^x04 %s^x01 (%s) has connected from^x03 %s^x01,^x03 %s^x01."szNameszIPszCityszCountry );
        else
            
ColorChat0BLUE"^x01*^x04 %s^x01 (%s) has connected from^x03 %s^x01."szNameszIPszCountry );
    }
    
// end of modifications
    
    
if( gflLongitude[id] != 0.0 && gflLatitude[id] != 0.0 )
        
set_task0.2"PrintDistance"id ); // gay fix.
    
    
return PLUGIN_CONTINUE;
}

public 
PrintDistanceid ) {
    static 
iszName32 ];
    
get_user_nameidszName31 );
    
    for( 
1<= gMaxplayersi++ )
        if( 
gIsUserConnected[i] && id != )
            if( 
gflLongitude[i] != 0.0 && gflLatitude[i] != 0.0 )
                
ColorChatiRED"^x01*^x04 %s^x01 is about^x03 %d^x01 kilometers far away from you."szNamefloatroundgeoip_distancegflLatitude[id], gflLatitude[i], gflLongitude[id], gflLongitude[i] ) ) );
}

public 
client_disconnectid ) {
    
gIsUserConnected[id] = false;
    
    if( 
is_user_botid ) )
        return 
PLUGIN_CONTINUE;
    
    new 
szIP[32], szCountry[46], szCity[46], szName[32];
    
get_user_name(idszName31);
    
get_user_ipidszIP31);
    
geoip_countryszIPszCountry );
    
geoip_cityszIPszCity );
    
    if( 
equal(szCountry"error") ) {
        if( !
contain(szIP"192.168.") || !contain(szIP"10. ") || !contain(szIP"172.") || equal(szIP"127.0.0.1") )
            
szCountry "LAN";
        
        else if( 
equal(szIP"loopback") )
            
szCountry "LAN Owner";
        
        else
            
szCountry "Unknown Country";
    }
    
    if( 
get_user_flags(id) & ADMIN_KICK ) {
        if( !
equalszCity"error" ) )
            
ColorChat0BLUE"^x01* Admin^x04 %s^x01 has disconnected from^x03 %s^x01,^x03 %s^x01."szNameszCityszCountry );
        else
            
ColorChat0BLUE"^x01* Admin^x04 %s^x01 has disconnected from^x03 %s^x01."szNameszCountry );
    } else {
        if( !
equalszCity"error" ) )
            
ColorChat0BLUE"^x01*^x04 %s^x01 has disconnected from^x03 %s^x01,^x03 %s^x01."szNameszCityszCountry );
        else
            
ColorChat0BLUE"^x01*^x04 %s^x01 has disconnected from^x03 %s^x01."szNameszCountry );
    }
    
    return 
PLUGIN_CONTINUE;
}

stock Float:geoip_distanceFloat:flLat1Float:flLat2Float:flLon1Float:flLon2 )
    return ( 
6371.0 floatacosfloatsinflLat1 57.3 ) * floatsinflLat2 57.3 ) + floatcosflLat1 57.3 ) * floatcosflLat2 57.3 ) * floatcosflLon2 57.3 flLon1 57.3 ), ) ) 
Apply the same modifications to the disconnecting code if you want.
Seta00 is offline
Seta00
The Seta00 user has crashed.
Join Date: Jan 2010
Location: Berlin
Old 02-08-2010 , 07:38   Re: CityConnectAnnouncer
Reply With Quote #3

I was trying to install this plugin on my server and got this:
Code:
( 22) Load fails: Plugin uses an unknown function (name "geoip_longitude") - check your modules.ini.
45 plugins, 44 running
Where plugin 22 is City Connect Announcer. Here's my amx_modules output:
Code:
] amx_modules
Currently loaded modules:
name                    version      author                state     
GeoIP                   1.8.1.3746  AMX Mod X Dev Team   running    
GeoIP SE                2.0         Eugene N.            running    
Fun                     1.8.1.3746  AMX Mod X Dev Team   running    
Engine                  1.8.1.3746  AMX Mod X Dev Team   running    
FakeMeta                1.8.1.3746  AMX Mod X Dev Team   running    
CStrike                 1.8.1.3660  AMX Mod X Dev Team   running    
Ham Sandwich            1.8.1.3746  AMX Mod X Dev Team   running    
CSX                     1.8.1.3666  AMX Mod X Dev Team   running    
8 modules
Seta00 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 02-08-2010 , 08:48   Re: CityConnectAnnouncer
Reply With Quote #4

Use this one http://forums.alliedmods.net/showthread.php?t=95665


#include <geoipse>
#include <geoip>

and you need only #include <geoip>
__________________
Arkshine is offline
Seta00
The Seta00 user has crashed.
Join Date: Jan 2010
Location: Berlin
Old 02-08-2010 , 14:59   Re: CityConnectAnnouncer
Reply With Quote #5

Thanks Arkshine, I've found it by myself anyway, but thanks.
Seta00 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:29.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode