SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 25/04/2012, 07:57 PM   #1
iggy1
High-roller
 
iggy1's Avatar
 
Join Date: Mar 2009
Location: One past the end.
Posts: 2,383
Reputation: 235
Default OnRetrieveIpLocation(playerid, country[]) (1.1)

Ip Locator 1.1

What does it do?

Quite simple, it adds a callback that gets called just after a player connects. The players country and city are sent to a the callback as two strings. The data is retrieved from this site http://www.hostip.info/

When a player connects a HTTP get request is sent with the players ip to the site above, when the site responds OnRetrieveIpLocation will be called. (after everything in OnPlayerConnect)


Example FS
pawn Code:
#define FILTERSCRIPT

#include <a_samp>
#include <iploc>

public OnFilterScriptInit()
{
    return 1;
}

public OnRetrieveIpLocation(playerid, country[])
{

    new
        szStr[ 64 ];

    GetPlayerName( playerid, szStr, MAX_PLAYER_NAME );

    format( szStr, sizeof( szStr ), "<SERVER> Welcome %s to the server. From %s", szStr, country );

    SendClientMessageToAll( -1, szStr );

}

public OnPlayerConnect( playerid )
{
    return 1;
}

NOTE: If an ip isn't stored on that site it's country will be "Private country" (this happens with localhost too). I could also add lat/lon but i thought that would be pretty pointless.

If anyone spots any bugs please point them out and ill try fix em.

UPDATE 1.1
  • Code re-written much more efficient and should hopefully work on linux.
  • Callback no longer has city argument, it was too inaccurate on all free sites i could find.

Download: http://dl.dropbox.com/u/76608104/iploc1.1.inc

Alternative:
If this isn't what your after try slices plugin free GeoIp filterscript.
Slices plugin free GeoIp: http://forum.sa-mp.com/showthread.php?t=190699
__________________
Quote:
Originally Posted by Y_Less
That code compiles perfectly, but I can tell you now it won't make me a cup of tea.
"No offense, but you are a stupid asshole." - Ron Burgundy

Last edited by iggy1; 01/05/2012 at 09:42 AM. Reason: Added geoip FS link
iggy1 is offline   Reply With Quote
Old 25/04/2012, 08:03 PM   #2
[DOG]irinel1996
High-roller
 
[DOG]irinel1996's Avatar
 
Join Date: Jan 2010
Location: Canary Islands, Spain
Posts: 1,625
Reputation: 210
Default Respuesta: Ip Locator Adds Callback OnRetrieveIpLocation(playerid, country[], city[])

Pretty nice man, like it. Short but useful. 5/5
__________________
STELLA HOSTING
Coming Soon
[DOG]irinel1996 is offline   Reply With Quote
Old 25/04/2012, 08:34 PM   #3
Edvin
Gangsta
 
Edvin's Avatar
 
Join Date: Dec 2010
Posts: 919
Reputation: 63
Default Re: Ip Locator Adds Callback OnRetrieveIpLocation(playerid, country[], city[])

Nice, ... i will try it tomorrow, if works perfectlly, i will use it !
Edvin is offline   Reply With Quote
Old 26/04/2012, 03:12 PM   #4
Niko_boy
High-roller
 
Niko_boy's Avatar
 
Join Date: Aug 2010
Location: Somewhere i belong
Posts: 1,414
Reputation: 137
Default Re: Ip Locator Adds Callback OnRetrieveIpLocation(playerid, country[], city[])

this is nice and this will be may be more accurate
A Question:
Can i use it to retrieve info customly e.g.
a command /getloc <playerid> and get his ip in command and use it some how ? or it works only in OnPlayerConnect?
i mean if there be stock or something will make this more cool :/
EDIT: i trying it now , but its no working O.o
__________________
$$$ If anyone want to get any of these:
  • DM/TDM/Freeroam/Stunt server, filterscripts or Bug fixing.or some general mapping. Above all any of the logos and banners or signature sorta stuff aswell.at some cheap and worth-full prices.
can Contact me for more info or a deal.
•••[0.3x]LCS•Freeroam•DM•Stunts•Race•Parkour•••AutoArena [0.3z][No SkinShot][sixtytiger.com]Want a decent Attack Defend Gamemode?
176.31.120.76:7777176.31.229.148:7830Get This! Attack-Defend(v2.3.1)

Last edited by Niko_boy; 26/04/2012 at 03:52 PM.
Niko_boy is online now   Reply With Quote
Old 26/04/2012, 03:22 PM   #5
TheArcher
High-roller
 
TheArcher's Avatar
 
Join Date: Dec 2009
Location: Home
Posts: 2,493
Reputation: 229
Default Re: Ip Locator Adds Callback OnRetrieveIpLocation(playerid, country[], city[])

Nice way do detect and quite fast. Good job.
__________________
TheArcher is online now   Reply With Quote
Old 26/04/2012, 03:44 PM   #6
InfinityCOD
Huge Clucker
 
Join Date: Apr 2012
Location: Inside SA-MP
Posts: 346
Reputation: 47
Default Re: Ip Locator Adds Callback OnRetrieveIpLocation(playerid, country[], city[])

Nice! Good Job nice and clean!
InfinityCOD is offline   Reply With Quote
Old 26/04/2012, 04:12 PM   #7
iggy1
High-roller
 
iggy1's Avatar
 
Join Date: Mar 2009
Location: One past the end.
Posts: 2,383
Reputation: 235
Default Re: Ip Locator Adds Callback OnRetrieveIpLocation(playerid, country[], city[])

Quote:
Originally Posted by Niko_boy View Post
this is nice and this will be may be more accurate
A Question:
Can i use it to retrieve info customly e.g.
a command /getloc <playerid> and get his ip in command and use it some how ? or it works only in OnPlayerConnect?
i mean if there be stock or something will make this more cool :/
EDIT: i trying it now , but its no working O.o
It returns "private country" if you connect from your localhost. ie if you connect to your home-hosted server. Next update i will get it to display "Local host" in that case.

You could also make that command yourself with the callback provided, just store the country/city in an array, and have a function return it. (or just use the var in the command)

If i added a function to get the players country, people would more than likely use it in OnPlayerConnect and it wouldn't work. I thought a callback would be the simplest way. If there was a way for me to get the HTTP response instantly i would have added more funcs.

Thanks all for positive feedback.
__________________
Quote:
Originally Posted by Y_Less
That code compiles perfectly, but I can tell you now it won't make me a cup of tea.
"No offense, but you are a stupid asshole." - Ron Burgundy
iggy1 is offline   Reply With Quote
Old 26/04/2012, 04:16 PM   #8
Niko_boy
High-roller
 
Niko_boy's Avatar
 
Join Date: Aug 2010
Location: Somewhere i belong
Posts: 1,414
Reputation: 137
Default Re: Ip Locator Adds Callback OnRetrieveIpLocation(playerid, country[], city[])

Quote:
Originally Posted by iggy1 View Post
Thanks all for positive feedback.
Welcome.
Quote:
Originally Posted by iggy1 View Post
It returns "private country" if you connect from your localhost. ie if you connect to your home-hosted server. Next update i will get it to display "Local host" in that case.
But ^
it must say Private COuntry , but it isnt doing so O.o ?
nor it called the Function... OnRetrieveIpLocation
.. i tried to debug where it is CallLocalFunction("onretrieve.. and debug also showed no results .. ?
wtabout that ?
__________________
$$$ If anyone want to get any of these:
  • DM/TDM/Freeroam/Stunt server, filterscripts or Bug fixing.or some general mapping. Above all any of the logos and banners or signature sorta stuff aswell.at some cheap and worth-full prices.
can Contact me for more info or a deal.
•••[0.3x]LCS•Freeroam•DM•Stunts•Race•Parkour•••AutoArena [0.3z][No SkinShot][sixtytiger.com]Want a decent Attack Defend Gamemode?
176.31.120.76:7777176.31.229.148:7830Get This! Attack-Defend(v2.3.1)
Niko_boy is online now   Reply With Quote
Old 26/04/2012, 04:18 PM   #9
iggy1
High-roller
 
iggy1's Avatar
 
Join Date: Mar 2009
Location: One past the end.
Posts: 2,383
Reputation: 235
Default Re: Ip Locator Adds Callback OnRetrieveIpLocation(playerid, country[], city[])

I'll just check it again now, i'm quite sure it was working when i posted it. I will edit this post.

EDIT: It works for me, check your server log for the http response.

pawn Code:
#include <a_samp>
#include <iploc>

public OnRetrieveIpLocation(playerid, country[], city[])
{

    printf("playerid %d, joined from country %s, city %s", playerid, country, city);

}

main()
{
    print("\n----------------------------------");
    print("The most blank GM in the world!!!");
    print("----------------------------------\n");
}


public OnGameModeInit()
{
    return 1;
}

server_log:
Code:
[17:37:41] playerid 0, joined from country private country, city private address
__________________
Quote:
Originally Posted by Y_Less
That code compiles perfectly, but I can tell you now it won't make me a cup of tea.
"No offense, but you are a stupid asshole." - Ron Burgundy
iggy1 is offline   Reply With Quote
Old 26/04/2012, 04:45 PM   #10
Niko_boy
High-roller
 
Niko_boy's Avatar
 
Join Date: Aug 2010
Location: Somewhere i belong
Posts: 1,414
Reputation: 137
Default Re: Ip Locator Adds Callback OnRetrieveIpLocation(playerid, country[], city[])

Nop nothing in there :/

Quote:
[21:55:27] OnGameo
[21:55:27]
--------------------------------------
[21:55:27] Iggys Ip Locator Loaded.
[21:55:27] --------------------------------------

[21:55:27]
----------------------------------
[21:55:27] Running LVDM ~MoneyGrub

[21:55:27] Coded By
[21:55:27] Jax
[21:55:27] ----------------------------------

[21:55:27] Number of vehicle models: 48
[21:55:40] Incoming connection: 192.168.1.3:59081
[21:55:40] [join] Niko_boy has joined the server (0:192.168.1.3)
[22:02:34] [part] Niko_boy has left the server (0:1)

and i use code u posted in ur first post no message is send + as i said earleir the Fucntion isnt gettign called.
aight i g2g atm :. i will get back to thread and try the script tommorow again :
__________________
$$$ If anyone want to get any of these:
  • DM/TDM/Freeroam/Stunt server, filterscripts or Bug fixing.or some general mapping. Above all any of the logos and banners or signature sorta stuff aswell.at some cheap and worth-full prices.
can Contact me for more info or a deal.
•••[0.3x]LCS•Freeroam•DM•Stunts•Race•Parkour•••AutoArena [0.3z][No SkinShot][sixtytiger.com]Want a decent Attack Defend Gamemode?
176.31.120.76:7777176.31.229.148:7830Get This! Attack-Defend(v2.3.1)
Niko_boy is online now   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
[Include] GeoIP (ISP, Country, City) Whitetiger Includes 95 16/05/2014 05:11 PM
How to get playerid under such callback as OnVehicleSpawn [WSF]ThA_Devil Help Archive 7 01/08/2011 01:53 PM
Favorite Country Side City? Darklom Everything and Nothing 15 22/03/2011 01:18 AM
OnPlayerInfoChange(playerid) callback ledzep Help Archive 7 08/04/2009 02:05 AM


All times are GMT. The time now is 05:57 PM.


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