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

Module: GeoIP+ (v1.3)


Post New Thread Reply   
 
Thread Tools Display Modes
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 06-26-2009 , 07:38   Re: Module: GeoIP Extended
Reply With Quote #11

I've kept the same design like geoip_code[2|3]_ex() where it returns true on a successful lookup, false on a failed lookup. It will not return "err" btw. But I understand what you mean, though you can avoid to create another var depending how you code.
__________________

Last edited by Arkshine; 06-26-2009 at 18:38.
Arkshine is offline
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 06-26-2009 , 08:33   Re: Module: GeoIP Extended
Reply With Quote #12

Why even make the continent a string?
I mean, you still have to use an array.
[ --<-@ ] Black Rose is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 06-26-2009 , 08:43   Re: Module: GeoIP Extended
Reply With Quote #13

Sorry Superiority, I don't understand well what you mean.
__________________
Arkshine is offline
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 06-26-2009 , 09:40   Re: Module: GeoIP Extended
Reply With Quote #14

... IT'S ENGLISH!

omfg...

Make this
Code:
native bool:geoip_continent_code( const ip[], result[3] );
into this
Code:
native bool:geoip_continent_code( const ip[], result );
or maby even this
Code:
native geoip_continent_code( const ip[] );
I vote option 2.
Make it return an integer instead of a string.
[ --<-@ ] Black Rose is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 06-26-2009 , 09:46   Re: Module: GeoIP Extended
Reply With Quote #15

Quote:
... IT'S ENGLISH!

omfg...
My english fails often. No need to react like that. -_-'

Still I don't understand because the continent code is composed of 2 characters so the output would be a string not integer.

If not, explain better.
__________________
Arkshine is offline
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 06-26-2009 , 10:06   Re: Module: GeoIP Extended
Reply With Quote #16

Quote:
Originally Posted by arkshine View Post
My english fails often. No need to react like that. -_-'

Still I don't understand because the continent code is composed of 2 characters so the output would be a string not integer.

If not, explain better.
Exactly, why waste precious processor power, memory & time with strings?
You still need an array of the continents to use the full name. No one would ever use a 2 char code. That's only for comparsion/logs, and the comparsion would be even easier with integers.

Code:
#define Europe 1
#define Africa 2
// et.c.
 
// ...
 
new Contintent[][] = {
   "",
   "Europe",
   "Africa"
}
 
// ...
 
new ip[32];
get_user_ip(id, ip, 31);
server_print("Whatever: %s", Contintent[geoip_continent_code(ip);
[ --<-@ ] Black Rose is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 06-26-2009 , 10:32   Re: Module: GeoIP Extended
Reply With Quote #17

Ok, now I understand. I would need to replace in the GeoIP code the continent code by numbers. But I would prefer to keep the characters since it can be useful for some people. ( like geoip_code[2|3]_ex() ). Then what about to return an integer AND to pass the characters but as optional param, people could do a choice so.
__________________
Arkshine is offline
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 06-26-2009 , 11:13   Re: Module: GeoIP Extended
Reply With Quote #18

Quote:
Originally Posted by arkshine View Post
Ok, now I understand. I would need to replace in the GeoIP code the continent code by numbers. But I would prefer to keep the characters since it can be useful for some people. ( like geoip_code[2|3]_ex() ). Then what about to return an integer AND to pass the characters but as optional param, people could do a choice so.
Your way seems really good.
[ --<-@ ] Black Rose is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 06-27-2009 , 03:09   Re: Module: GeoIP Extended
Reply With Quote #19

Since I suck in english, I have some difficulty with the .inc.
Here the new version for geoip_continent_code().
Is someone can correct it since I'm not sure if it's well written or needs changes. I just want something perfect in english.

Code:
/**  * Lookup the continent code for a given IP address.  *  * @note The code can be retrieved as integer number or string (2 characters).  * @note Possible continent codes are AF, AS, EU, NA, OC, SA for  * Africa(1), Asia(2), Europe(3), North America(4), Oceania(5) and South America(6).  *  * @param ip        The IP address to lookup.  * @param result    The result of the geoip lookup. This param is optional.  *                  If the lookup does not succeed, the buffer is not modified.  * @return          The result of the geoip lookup, 0 on a failed lookup.  */ enum Continent {     AFRICA = 1,     ASIA,     EUROPE,     NORTH_AMERICA,     OCEANIA,     SOUTH_AMERICA } native Continent:geoip_continent_code( const ip[], result[3] = "" );
__________________

Last edited by Arkshine; 06-27-2009 at 03:13.
Arkshine is offline
diamond-optic
Veteran Member
Join Date: May 2005
Location: Upstate New York
Old 06-27-2009 , 11:09   Re: Module: GeoIP Extended
Reply With Quote #20

this is great... i just installed vc++ the other day and was gonna try and do this myself.. saved me the trouble :-)


only issue i have, is sometimes certain IPs seem to crash the server


like i setup a simple test plugin with a cmd to input my own IP and just started grabbing IPs from players on my server and running them thru it, and every now and then id get one that made the server crash


i wish i had wrote down the IP so that i could post it here for others to try
__________________
diamond-optic is offline
Send a message via AIM to diamond-optic
Reply


Thread Tools
Display Modes

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 14:38.


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