SA-MP Forums Archive
[FilterScript] Plugin-free GeoIP - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+--- Thread: [FilterScript] Plugin-free GeoIP (/showthread.php?tid=190699)

Pages: 1 2


Plugin-free GeoIP - Slice - 16.11.2010

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


Re : Plugin-free GeoIP - Hip-hop - 16.11.2010

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


Re: Plugin-free GeoIP - Slice - 16.11.2010

According to ******, Romanian people also say salut.


Re: Re : Plugin-free GeoIP - Gavibro - 16.11.2010

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.


Re: Plugin-free GeoIP - mmrk - 16.11.2010

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 ) );
    }
}



Re: Plugin-free GeoIP - MicroD - 16.11.2010

Do you have and the Serbian language?

Sory for my bad English

I found


Re: Plugin-free GeoIP - Slice - 16.11.2010

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!


Re: Plugin-free GeoIP - mmrk - 16.11.2010

Works now.

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



Re: Plugin-free GeoIP - Slice - 16.11.2010

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 );
}



Re: Plugin-free GeoIP - Zh3r0 - 16.11.2010

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.


Re: Plugin-free GeoIP - Skaizo - 16.11.2010

very nice


Re: Plugin-free GeoIP - SkizzoTrick - 16.11.2010

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


Re: Plugin-free GeoIP - Tr1viUm - 16.11.2010

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.


Re: Plugin-free GeoIP - Scenario - 16.11.2010

This is amazing, very nice work!


Re: Plugin-free GeoIP - MicroD - 16.11.2010

I am from Serbia and writes me unknow


Re: Plugin-free GeoIP - Slice - 16.11.2010

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?


Re: Plugin-free GeoIP - playbox12 - 16.11.2010

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


Re: Plugin-free GeoIP - [H]265 - 16.11.2010

Nice work keep up good work


Re: Plugin-free GeoIP - Slice - 16.11.2010

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.


Re: Plugin-free GeoIP - playbox12 - 16.11.2010

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