[FilterScript] Plugin-free GeoIP
#1

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 Код:
#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 Код:
GetPlayerCountryIndex( playerid ); // Example: 19
GetPlayerCountryName( playerid ); // Example: Sweden
GetPlayerCountryCode( playerid ); // Example: SE
Country Indexes
See this link: http://slice.pastebay.org/109849
Reply
#2

Very nice !
Salut = French but you put case COUNTRY_RO ??
not case COUNTRY_FR ?
Reply
#3

According to ******, Romanian people also say salut.
Reply
#4

Easy...so easy,but for you xD,some lines bewilder me.
GJ,all your scripts are original!
Quote:
Originally Posted by Hip-hop
Посмотреть сообщение
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.
Reply
#5

Im from Estonia

Код:
[14:49:16] Test: mmrk connected from sweaden
Test code:
pawn Код:
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 ) );
    }
}
Reply
#6

Do you have and the Serbian language?

Sory for my bad English

I found
Reply
#7

Quote:
Originally Posted by mmrk
Посмотреть сообщение
Im from Estonia

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

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

Works now.

Код:
[15:18:17] Test: mmrk connected from estonia
Reply
#9

Quote:
Originally Posted by mmrk
Посмотреть сообщение
Works now.

Код:
[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 Код:
printf( "%s connected from %s.", name, GetPlayerCountryName( playerid ) );
The country index should be used for stuff like this (well, preferably not ):
pawn Код:
if ( GetPlayerCountryIndex( playerid ) == COUNTRY_SE )
{
    SendClientMessage( playerid, -1, "No blond people allowed!" );
   
    Kick( playerid );
}
Reply
#10

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.
Reply
#11

very nice
Reply
#12

Nice,very nice
And yes,romanian's say salut like french xD
Reply
#13

Quote:
Originally Posted by Zh3r0
Посмотреть сообщение
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.
They could do that anyway by using ranged bans.
Reply
#14

This is amazing, very nice work!
Reply
#15

I am from Serbia and writes me unknow
Reply
#16

Quote:
Originally Posted by David Skrbic
Посмотреть сообщение
I am from Serbia and writes me unknow
I'm going to make some additions to the GeoIP lookup script; it should say serbia in a couple days. Could you PM me your IP?
Reply
#17

Its looks good, one suggestion though. NL and BE are basicly the same in Belgium you either speak Dutch or French
Reply
#18

Nice work keep up good work
Reply
#19

Quote:
Originally Posted by playbox12
Посмотреть сообщение
Its looks good, one suggestion though. NL and BE are basicly the same in Belgium you either speak Dutch or French
Well geographically they're different.
Reply
#20

Quote:
Originally Posted by g_aSlice
Посмотреть сообщение
Well geographically they're different.
I know, but in your example, you basicly said something Dutch for the Belgium thingy. I misunderstood it actually, I was just looking at the example script and gave a suggestion on that lol .

Script is still nice though
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)