samp.directory
← Skrypty i biblioteki

Southclaws/samp-geoip

A simple library that provides information from IPHub for connected players.

Biblioteka★ 14zaktualizowano lip 2020Brak licencjiPawnsampctlZarchiwizowane
Otwórz na GitHubie

Autor zarchiwizował to repozytorium, więc nie jest już rozwijane.

To repozytorium nie ma pliku licencji. Jest publiczne do odczytu, ale samo to nie daje pozwolenia na ponowne użycie.

Zainstaluj za pomocą sampctl

sampctl package install Southclaws/samp-geoip

Uruchom to w folderze swojego projektu. sampctl pobiera pakiet i to, od czego zależy.

Wypróbuj w kompilatorze Pawn →

Dodaje jej pliki include, razem z bibliotekami, od których zależy, do kompilatora Pawn w twojej przeglądarce, gotowe do dołączenia w skrypcie.

Zależy od 5 pakietów

README.md

samp-geoip

A simple library that provides information from IPHub for connected players.

This package is built using the Requests package which is used to perform a web request to IPHub's API when a player connects.

Currently the results are not cached so you may encounter rate limits if your server has many players connecting per minute. This may be addressed in future by using Redis as a cache.

Installation

Simply install to your project:

sampctl package install Southclaws/samp-geoip

Include in your code and begin using the library:

#include <geoip>

Usage

When a player connects, their details are automatically requested. Once the response has arrived, the API can be used.

bool:IsGeoDataReady(playerid) Checks if the data is ready, requests should only take milliseconds but this ensures your code doesn't attempt to request data that isn't ready yet.

The rest of the API corresponds directly to the IPHub documentation:

  • GetPlayerCountryCode(playerid, output[], len = sizeof output)
  • GetPlayerCountryName(playerid, output[], len = sizeof output)
  • GetPlayerASN(playerid, &asn)
  • GetPlayerISP(playerid, output[], len = sizeof output)
  • GetPlayerIPBlock(playerid, &block)

There is also an event that is called when the data is available:

  • OnGeoDataReady(playerid)

Testing

To test, first you must build build the package with the file iphub_key.inc which should consist of:

#define IPHUB_KEY your_api_key

You can get a free API key from this page by clicking Looking for the free plan (2000 req/day)? Here!

Then just run as normal and connect to localhost:7777:

sampctl package run

If you connect locally, you'll see no useful data because you'll be sending the loopback interface address, but a response will still appear:

text="requesting ip data" addr="127.0.0.1" playerid=0
text="received ip data" request=0 status=200
text="determined target player for ip data" playerid=0
text="extracted ip data for player" code="ZZ" name="Unknown" asn=0 isp="Private/local IP" block=0

You can also type /ip in-game to see a message containing the data.

geolocationiphubpawn-packagesa-mpsa-mp-library

Ta strona jest zbudowana z tego, co GitHub publikuje o repozytorium. samp.directory nie hostuje kodu. Zgłoś problem z tym wpisem

Southclaws/samp-geoip: Biblioteka SA-MP | samp.directory