Raised This Month: $51 Target: $400
 12% 

[GEOIP] geoip_code2 always return "err"


  
 
 
Thread Tools Display Modes
Author Message
KCE
Senior Member
Join Date: Jan 2005
Location: Los Angeles, CA
Old 07-06-2006 , 21:28   [GEOIP] geoip_code2 always return "err"
#1

With latest version of Amx Mod X, geoip_code2 always returns "err". Someone also posted a problem in the wiki.

Quote:
Use ccode[4] instead of ccode[3] for security reasons. In case of failure, this function should return "err" string, making ccode[3] too short to include /0 char.

Alien

Last edited by KCE; 07-07-2006 at 21:41.
KCE is offline
SweatyBanana
BANNED
Join Date: Sep 2005
Location: LOL
Old 07-07-2006 , 09:06   Re: [GEOIP] geoip_code2 always return "err"
#2

Well this is how Hawk showed me to fix it with name changes, but if you were wanting to display it in chat, I dont know.

PHP Code:
fnChangeName(id,szName[],szShortCountry[])
    if(
containi(szName,szShortCountry) == -&& containi(szShortCountry,"err") == -1)
    {
        
remove_quotes(szName)
        if(
get_pcvar_num(g_pShowWhere))
            
client_cmd(id,"name ^"%[%s]^"",szName,szShortCountry)
        else
            
client_cmd(id,"name ^"[%s] %s^"",szShortCountry,szName)
    } 
SweatyBanana is offline
Send a message via AIM to SweatyBanana Send a message via Yahoo to SweatyBanana
KCE
Senior Member
Join Date: Jan 2005
Location: Los Angeles, CA
Old 07-07-2006 , 21:16   Re: [GEOIP] geoip_code2 always return "err"
#3

Ok I've done some more testing and got it to work:

Code:
// Get country on authorized
public client_authorized(id)
{
	if( !is_user_bot(id) )
	{
		new szCountryCode[5]
		new szIp[25]
		new szPort[25]
		new szAddress[25]
		get_user_ip(id,szIp,24)
		strtok(szIp, szAddress, 24, szPort, 24, ':') 		
		geoip_code2(szAddress,szCountryCode)
		strtolower(szCountryCode)	//convert all letters to lowercase
		format( g_szCountryCodeFile[id], 33, "countryflag_%s999", szCountryCode )
		server_print("Address: %s, CODE: %s", szAddress, g_szCountryCodeFile[id])
	}
}
For geoip_code2, when I removed the port number it worked. So, I believe that both the geoip_code2 and get_user_ip isn't removing the port?
__________________

My 3D Art: http://k-c-e.deviantart.com/

[img]http://img213.**************/img213/7132/userbar152416mp2.gif[/img]
[img]http://img65.**************/img65/5606/userbar152433ie5.gif[/img]
[img]http://img223.**************/img223/7576/userbar152440yk6.gif[/img]

Last edited by KCE; 07-07-2006 at 21:18.
KCE is offline
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 07-07-2006 , 21:29   Re: [GEOIP] geoip_code2 always return "err"
#4

All you need to do is use the get_user_ip(index, ip[], len, withoutport)

All you need to do is set withoutport to 1. No need to strtok.

Code:
#include <amxmodx> #include <geoip> new g_szCountryCodeFile[33] // Get country on authorized public client_authorized(id) {     if( !is_user_bot(id) )     {         new szCountryCode[3]         new szIp[25]         get_user_ip(id,szIp,24, 1)         geoip_code2(szIp, szCountryCode)         strtolower(szCountryCode)   //convert all letters to lowercase         format( g_szCountryCodeFile[id], 33, "countryflag_%s999", szCountryCode )         server_print("Address: %s, CODE: %s", szIp, g_szCountryCodeFile[id])     } }
__________________
No private support via Instant Message
GunGame:SM Released
teame06 is offline
Send a message via AIM to teame06
KCE
Senior Member
Join Date: Jan 2005
Location: Los Angeles, CA
Old 07-07-2006 , 21:31   Re: [GEOIP] geoip_code2 always return "err"
#5

Quote:
Originally Posted by teame06
All you need to do is use the get_user_ip(index, ip[], len, withoutport)

All you need to do is set withoutport to 1. No need to strtok.

Code:
#include <amxmodx> #include <geoip> new g_szCountryCodeFile[33] // Get country on authorized public client_authorized(id) {     if( !is_user_bot(id) )     {         new szCountryCode[3]         new szIp[25]         get_user_ip(id,szIp,24, 1)         geoip_code2(szIp, szCountryCode)         strtolower(szCountryCode)   //convert all letters to lowercase         format( g_szCountryCodeFile[id], 33, "countryflag_%s999", szCountryCode )         server_print("Address: %s, CODE: %s", szIp, g_szCountryCodeFile[id])     } }
LOL. I thought by setting it to 1, it INCLUDED the port number so I was setting it to 0...my bad

I think the problem with geoip_code2 is still there. In geoip.inc:

Quote:
//IP address can contain ports, the ports will be stripped out
So it should have worked either way.

I was doing this earlier:
Code:
// Get country on authorized public client_authorized(id) {     if( !is_user_bot(id) )     {         new szCountryCode[3]         new szIp[17]         get_user_ip(id,szIp,16,false) //false == 0         geoip_code2(szIp,szCountryCode)         strtolower(szCountryCode)   //convert all letters to lowercase         format( g_szCountryCodeFile[id], 33, "countryflag_%s999", szCountryCode )     } }
__________________

My 3D Art: http://k-c-e.deviantart.com/

[img]http://img213.**************/img213/7132/userbar152416mp2.gif[/img]
[img]http://img65.**************/img65/5606/userbar152433ie5.gif[/img]
[img]http://img223.**************/img223/7576/userbar152440yk6.gif[/img]

Last edited by KCE; 07-07-2006 at 21:38.
KCE is offline
BAILOPAN
Join Date: Jan 2004
Old 07-07-2006 , 23:31   Re: [GEOIP] geoip_code2 always return "err"
#6

So, are you currently having a problem with this using IPs without ports?
__________________
egg
BAILOPAN is offline
KCE
Senior Member
Join Date: Jan 2005
Location: Los Angeles, CA
Old 07-12-2006 , 03:18   Re: [GEOIP] geoip_code2 always return "err"
#7

Quote:
Originally Posted by BAILOPAN
So, are you currently having a problem with this using IPs without ports?
geoip_code2 not being able to handle ip's with ports although it says so in the include.
__________________

My 3D Art: http://k-c-e.deviantart.com/

[img]http://img213.**************/img213/7132/userbar152416mp2.gif[/img]
[img]http://img65.**************/img65/5606/userbar152433ie5.gif[/img]
[img]http://img223.**************/img223/7576/userbar152440yk6.gif[/img]

Last edited by KCE; 07-12-2006 at 03:20.
KCE is offline
BAILOPAN
Join Date: Jan 2004
Old 07-12-2006 , 12:57   Re: [GEOIP] geoip_code2 always return "err"
#8

Okay, acknowledged as a valid bug. It'll be fixed for the next release.
__________________
egg
BAILOPAN is offline
faluco
Developer
Join Date: Mar 2005
Location: Valencia, Spain
Old 07-13-2006 , 05:30   Re: [GEOIP] geoip_code2 always return "err"
#9

fixed thanks!
i'll upload the fix this night to SVN.
__________________
:F
faluco is offline
faluco
Developer
Join Date: Mar 2005
Location: Valencia, Spain
Old 07-13-2006 , 15:59   Re: [GEOIP] geoip_code2 always return "err"
#10

hello, here is the fixed module for you if you want to test
Attached Files
File Type: zip geoip_amxx.zip (31.3 KB, 220 views)
__________________
:F
faluco is offline
 



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 11:18.


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