diff --git a/dlls/geoip/geoip_amxx.cpp b/dlls/geoip/geoip_amxx.cpp index 80f63e2b..519672a5 100755 --- a/dlls/geoip/geoip_amxx.cpp +++ b/dlls/geoip/geoip_amxx.cpp @@ -218,6 +218,18 @@ static cell AMX_NATIVE_CALL amx_geoip_region_name(AMX *amx, cell *params) return MF_SetAmxString(amx, params[2], region ? region : "", length >= params[3] ? params[3] : length); // TODO: make this utf8 safe. } +// native geoip_timezone(const ip[], result[], len); +static cell AMX_NATIVE_CALL amx_geoip_timezone(AMX *amx, cell *params) +{ + int length; + char *ip = MF_GetAmxString(amx, params[1], 0, &length); + + const char *path[] = { "location", "time_zone", NULL }; + const char *timezone = lookupByIp(stripPort(ip), path, &length); + + return MF_SetAmxString(amx, params[2], timezone ? timezone : "", length >= params[3] ? params[3] : length); +} + void OnAmxxAttach() { @@ -288,6 +300,8 @@ AMX_NATIVE_INFO geoip_natives[] = { "geoip_region_code", amx_geoip_region_code }, { "geoip_region_name", amx_geoip_region_name }, + { "geoip_timezone", amx_geoip_timezone }, + { NULL, NULL }, }; diff --git a/plugins/include/geoip.inc b/plugins/include/geoip.inc index d27f3fdf..1badf802 100755 --- a/plugins/include/geoip.inc +++ b/plugins/include/geoip.inc @@ -120,4 +120,16 @@ native geoip_region_code(const ip[], result[], len); * * @return The result length on successful lookup, 0 otherwise. */ -native geoip_region_name(const ip[], result[], len); \ No newline at end of file +native geoip_region_name(const ip[], result[], len); + +/** + * Look up the full time zone for the given IP address. + * e.g. America/Los_Angeles, Europe/Paris. + * + * @param ip The IP address to look up. + * @param result The result of the geoip look up. + * @param len The maximum length of the result buffer. + * + * @return The result length on successful lookup, 0 otherwise. + */ +native geoip_timezone(const ip[], result[], len); \ No newline at end of file