Raised This Month: $51 Target: $400
 12% 

[ANY] SxGeo


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Accelerator
Senior Member
Join Date: Dec 2010
Location: Russia
Old 10-15-2018 , 06:36   [ANY] SxGeo
Reply With Quote #1

SxGeo

Sourcemod extension, using Sypex Geo API.

Installation:
  • Download the free version of the SxGeoCity database. Click: SxGeoCity.dat
  • Extract it to /addons/sourcemod/configs/geoip/
  • Extract file sxgeo.ext.so to folder addons/sourcemod/extensions; Extract file sxgeo.inc to folder addons/sourcemod/scripting/include.
  • Install any sm-plugin that requires the sxgeo extension.

Usage:
PHP Code:
// sxgeo.inc

/**
 * @section IP addresses can contain ports, the ports will be stripped out.
 */

/**
 * Gets the two character country code from an IP address. (US, CA, etc)
 *
 * @param ip            Ip to determine the country code.
 * @param ccode            Destination string buffer to store the code.
 * @return                True on success, false if no country found.
 */
native bool SxGeoCode(const char[] ipchar ccode[3]);

/**
 * Gets the full country name.
 *
 * @param ip            Ip to determine the country code.
 * @param name            Destination string buffer to store the country name.
 * @param maxlength            Maximum length of output string buffer.
 * @param lang       Which language to the output of result the sxgeo lookup.
 *                   Supported languages:
 *                   "ru", "en"
 *
 * @return                True on success, false if no country found.
 */
native bool SxGeoCountry(const char[] ipchar[] nameint maxlength, const char[] lang "en");

/**
 * Gets the city name.
 *
 * @param ip            Ip to determine the city code.
 * @param name            Destination string buffer to store the city name.
 * @param maxlength            Maximum length of output string buffer.
 * @param lang       Which language to the output of result the sxgeo lookup.
 *                   Supported languages:
 *                   "ru", "en"
 *
 * @return                True on success, false if no city found.
 */
native bool SxGeoCity(const char[] ipchar[] nameint maxlength, const char[] lang "en");

/**
 * Gets the full region name.
 *
 * @param ip            Ip to determine the region code.
 * @param name            Destination string buffer to store the region name.
 * @param maxlength            Maximum length of output string buffer.
 * @param lang       Which language to the output of result the sxgeo lookup.
 *                   Supported languages:
 *                   "ru", "en"
 *
 * @return                True on success, false if no region found.
 */
native bool SxGeoRegion(const char[] ipchar[] nameint maxlength, const char[] lang "en");

/**
 * Gets the city's latitude
 *
 * @param ip            Ip to determine the city latitude.
 * @return                The result of the latitude, 0 if latitude is not found
 */
native float SxGeoLatitude(const char[] ip);

/**
 * Gets the city's longitude
 *
 * @param ip            Ip to determine the city longitude.
 * @return                The result of the longitude, 0 if longitude is not found
 */
native float SxGeoLongitude(const char[] ip);

/*
 * Calculate the distance between geographical coordinates, latitude and longitude.
 *
 * @param lat1       The first IP latitude.
 * @param lon1       The first IP longitude.
 * @param lat2       The second IP latitude.
 * @param lon2       The second IP longitude.
 * @param system     The system of measurement, 0 = Metric(kilometers) or 1 = English(miles).
 *
 * @return           The distance as result in specified system of measurement.
 */

#define SYSTEM_METRIC   0 // kilometers
#define SYSTEM_IMPERIAL 1 // statute miles

native float SxGeoDistance(float lat1float lon1float lat2float lon2system SYSTEM_METRIC); 
Download: https://github.com/Accelerator74/SxGeo/releases
__________________

Last edited by Accelerator; 10-15-2018 at 13:51.
Accelerator is offline
 



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

Forum Jump


All times are GMT -4. The time now is 14:53.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode