SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 16/11/2010, 11:41 AM   #1
Slice
High-roller
 
Slice's Avatar
 
Join Date: Mar 2008
Location: Sweden
Posts: 1,861
Reputation: 1259
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, "zdravstvuyte." );
        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
__________________
Do you like SA-MP and DayZ? Come play both: ulclan.com:1421

Do you use any scripts I've made?
Star them on GitHub or reply in their topics so I know what I should keep working on!

Last edited by Slice; 12/05/2014 at 02:52 PM.
Slice is offline   Reply With Quote
Old 16/11/2010, 11:59 AM   #2
Hip-hop
Huge Clucker
 
Join Date: Jun 2009
Posts: 249
Reputation: 20
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, 12:00 PM   #3
Slice
High-roller
 
Slice's Avatar
 
Join Date: Mar 2008
Location: Sweden
Posts: 1,861
Reputation: 1259
Default Re: Plugin-free GeoIP

According to Google, Romanian people also say salut.
__________________
Do you like SA-MP and DayZ? Come play both: ulclan.com:1421

Do you use any scripts I've made?
Star them on GitHub or reply in their topics so I know what I should keep working on!
Slice is offline   Reply With Quote
Old 16/11/2010, 12:18 PM   #4
Gavibro
Big Clucker
 
Gavibro's Avatar
 
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, 12:42 PM   #5
mmrk
Big Clucker
 
Join Date: Nov 2008
Location: Estonia
Posts: 133
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, 12:50 PM   #6
MicroD
Gangsta
 
MicroD's Avatar
 
Join Date: Sep 2010
Posts: 525
Reputation: 20
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, 12:57 PM   #7
Slice
High-roller
 
Slice's Avatar
 
Join Date: Mar 2008
Location: Sweden
Posts: 1,861
Reputation: 1259
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!
__________________
Do you like SA-MP and DayZ? Come play both: ulclan.com:1421

Do you use any scripts I've made?
Star them on GitHub or reply in their topics so I know what I should keep working on!
Slice is offline   Reply With Quote
Old 16/11/2010, 01:09 PM   #8
mmrk
Big Clucker
 
Join Date: Nov 2008
Location: Estonia
Posts: 133
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, 01:11 PM   #9
Slice
High-roller
 
Slice's Avatar
 
Join Date: Mar 2008
Location: Sweden
Posts: 1,861
Reputation: 1259
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 );
}
__________________
Do you like SA-MP and DayZ? Come play both: ulclan.com:1421

Do you use any scripts I've made?
Star them on GitHub or reply in their topics so I know what I should keep working on!
Slice is offline   Reply With Quote
Old 16/11/2010, 01:18 PM   #10
Zh3r0
Godfather
 
Join Date: Mar 2008
Posts: 5,602
Reputation: 381
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 216 01/11/2014 05:23 PM


All times are GMT. The time now is 12:42 PM.


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