SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts

Reply
 
Thread Tools Display Modes
Old 16/11/2010, 10:41 AM   #1
Slice
High-roller
 
Slice's Avatar
 
Join Date: Mar 2008
Location: Sweden
Posts: 1,669
Reputation: 969
Default Plugin-free GeoIP

hey,
This will provide functionality to get what country a player is from. You can get the country name, code, and index (you can use the index and match it against a bunch of constants, example below).
No plug-ins, databases, or anything needed!

What you have to do
  1. Compile and load geoip.pwn.
  2. Put geoip.inc in your PAWN include folder.
  3. Put #include <geoip> at the top of any PAWN script you want to use the functions in.
Example usage
pawn Code:
#include <a_samp>
#include <geoip>

public OnGeoipUpdate( playerid )
{
    new
        message[ 32 + MAX_COUNTRY_NAME ]
    ;
   
    format( message, sizeof( message ), "Did I hear you're from %s?", GetPlayerCountryName( playerid ) );
   
    SendClientMessage( playerid, -1, message );
   
    switch ( GetPlayerCountryIndex( playerid ) )
    {
        case COUNTRY_SE: SendClientMessage( playerid, -1, "Välkommen." );
        case COUNTRY_HR: SendClientMessage( playerid, -1, "Bok." );
        case COUNTRY_RU: SendClientMessage( playerid, -1, "zdras-tvooy-tyeh." ); // :D
        case COUNTRY_NL: SendClientMessage( playerid, -1, "Hoi." );
        case COUNTRY_RO: SendClientMessage( playerid, -1, "Salut." );
        case COUNTRY_BE: SendClientMessage( playerid, -1, "Goedenmiddag." );
        case COUNTRY_AU: SendClientMessage( playerid, -1, "G'day mate." );
        case COUNTRY_IN: SendClientMessage( playerid, -1, "Namaste." );
        case COUNTRY_US: SendClientMessage( playerid, -1, "What's up." );
        case COUNTRY_GB: SendClientMessage( playerid, -1, "Wotcha." );
        case COUNTRY_DE: SendClientMessage( playerid, -1, "Guten tag." );
       
        default: SendClientMessage( playerid, -1, "Welcome." );
    }
}
Functions
pawn Code:
GetPlayerCountryIndex( playerid ); // Example: 19
GetPlayerCountryName( playerid ); // Example: Sweden
GetPlayerCountryCode( playerid ); // Example: SE
Country Indexes
See this link: http://slice.pastebay.org/109849
__________________

Known as [uL]Slice in-game. Feel free to come play some good ol' AAD at our server or visit our website.

Do you need a secure, strong SA-MP server? PM me and we can work something out (more than 80 slots).

Last edited by Slice; 11/10/2011 at 07:50 AM.
Slice is offline   Reply With Quote
Old 16/11/2010, 10:59 AM   #2
Hip-hop
Huge Clucker
 
Join Date: Jun 2009
Posts: 202
Reputation: 1
Default Re : Plugin-free GeoIP

Very nice !
Salut = French but you put case COUNTRY_RO ??
not case COUNTRY_FR ?
__________________

Hip-hop is offline   Reply With Quote
Old 16/11/2010, 11:00 AM   #3
Slice
High-roller
 
Slice's Avatar
 
Join Date: Mar 2008
Location: Sweden
Posts: 1,669
Reputation: 969
Default Re: Plugin-free GeoIP

According to Google, Romanian people also say salut.
__________________

Known as [uL]Slice in-game. Feel free to come play some good ol' AAD at our server or visit our website.

Do you need a secure, strong SA-MP server? PM me and we can work something out (more than 80 slots).
Slice is offline   Reply With Quote
Old 16/11/2010, 11:18 AM   #4
Gavibro
Banned
 
Join Date: Nov 2010
Location: Afrika
Posts: 64
Reputation: 5
Default Re: Re : Plugin-free GeoIP

Easy...so easy,but for you xD,some lines bewilder me.
GJ,all your scripts are original!
Quote:
Originally Posted by Hip-hop View Post
Very nice !
Salut = French but you put case COUNTRY_RO ??
not case COUNTRY_FR ?
Romanian and French languages come from the Latin language and many words resemble each other.
Gavibro is offline   Reply With Quote
Old 16/11/2010, 11:42 AM   #5
mmrk
Big Clucker
 
Join Date: Nov 2008
Location: Estonia
Posts: 134
Reputation: 0
Default Re: Plugin-free GeoIP

Im from Estonia

Code:
[14:49:16] Test: mmrk connected from sweaden
Test code:
pawn Code:
public OnGeoipUpdate( playerid )
{
    switch ( GetPlayerCountryIndex( playerid ) )
    {
        case COUNTRY_SE: SendClientMessage( playerid, -1, "Välkommen." ), printf( "Test: %s connected from sweaden", Name( playerid ) );
        case COUNTRY_DE: SendClientMessage( playerid, -1, "Guten tag." ), printf( "Test: %s connected from germany", Name( playerid ) );
        case COUNTRY_EE: SendClientMessage( playerid, -1, "Tere." ), printf( "Test: %s connected from estonia", Name( playerid ) );
        case COUNTRY_RS: SendClientMessage( playerid, -1, "Alo." ), printf( "Test: %s connected from romania", Name( playerid ) );
       
        default: SendClientMessage( playerid, -1, "Welcome." ), printf( "Test: %s connected from default", Name( playerid ) );
    }
}
mmrk is offline   Reply With Quote
Old 16/11/2010, 11:50 AM   #6
MicroD
Huge Clucker
 
MicroD's Avatar
 
Join Date: Sep 2010
Posts: 349
Reputation: 9
Default Re: Plugin-free GeoIP

Do you have and the Serbian language?

Sory for my bad English

I found
MicroD is offline   Reply With Quote
Old 16/11/2010, 11:57 AM   #7
Slice
High-roller
 
Slice's Avatar
 
Join Date: Mar 2008
Location: Sweden
Posts: 1,669
Reputation: 969
Default Re: Plugin-free GeoIP

Quote:
Originally Posted by mmrk View Post
Im from Estonia

Code:
[14:49:16] Test: mmrk connected from sweaden
Test code:
pawn Code:
...
Could you PM me your IP?

Edit: Re-download geoip.pwn, I forgot to remove some debugging stuff that makes everyone Swedish!
__________________

Known as [uL]Slice in-game. Feel free to come play some good ol' AAD at our server or visit our website.

Do you need a secure, strong SA-MP server? PM me and we can work something out (more than 80 slots).
Slice is offline   Reply With Quote
Old 16/11/2010, 12:09 PM   #8
mmrk
Big Clucker
 
Join Date: Nov 2008
Location: Estonia
Posts: 134
Reputation: 0
Default Re: Plugin-free GeoIP

Works now.

Code:
[15:18:17] Test: mmrk connected from estonia
mmrk is offline   Reply With Quote
Old 16/11/2010, 12:11 PM   #9
Slice
High-roller
 
Slice's Avatar
 
Join Date: Mar 2008
Location: Sweden
Posts: 1,669
Reputation: 969
Default Re: Plugin-free GeoIP

Quote:
Originally Posted by mmrk View Post
Works now.

Code:
[15:18:17] Test: mmrk connected from estonia
You're probably just testing with the switch statement, but just to make sure I thought I'd mention you should do it like this:
pawn Code:
printf( "%s connected from %s.", name, GetPlayerCountryName( playerid ) );

The country index should be used for stuff like this (well, preferably not ):
pawn Code:
if ( GetPlayerCountryIndex( playerid ) == COUNTRY_SE )
{
    SendClientMessage( playerid, -1, "No blond people allowed!" );
   
    Kick( playerid );
}
__________________

Known as [uL]Slice in-game. Feel free to come play some good ol' AAD at our server or visit our website.

Do you need a secure, strong SA-MP server? PM me and we can work something out (more than 80 slots).
Slice is offline   Reply With Quote
Old 16/11/2010, 12:18 PM   #10
Zh3r0
Godfather
 
Join Date: Mar 2008
Posts: 5,609
Reputation: 377
Default Re: Plugin-free GeoIP

LOL, at the code above, this could be a racist script, i mean they can ban a whole country.

Very nice.

And yes "Salut" means in English Haiiiii tharrr durr durr.
__________________
Zh3r0 is offline   Reply With Quote
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Plugin] GeoIP Plugin v0.1.4 (Country detector) - 04/05/2008 Totto8492 Plugin Development 197 28/04/2013 02:35 PM


All times are GMT. The time now is 05:19 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.