04.06.2016, 18:13
Код:
public HTTP_OnLookupResponse(index, response, data[]) { new pos = -1; if (!IsPlayerConnected(index)) return 0; else if (response == 200) { if (strfind(data, "Reserved", true) != -1 || strlen(data) < 15) { return 0; } else { new country[MAX_COUNTRY_NAME],region[MAX_COUNTRY_NAME],city[MAX_COUNTRY_NAME],isp[MAX_COUNTRY_NAME]; if ((pos = strfind(data, "\"country\":")) != -1) { pos = pos + 11; strmid(country, data, pos, strfind(data, "\"", true, pos), MAX_COUNTRY_NAME); } if ((pos = strfind(data, "\"regionName\":")) != -1) { pos = pos + 14; strmid(region, data, pos, strfind(data, "\"", true, pos), MAX_COUNTRY_NAME); } if ((pos = strfind(data, "\"city\":")) != -1) { pos = pos + 8; strmid(city, data, pos, strfind(data, "\"", true, pos), MAX_COUNTRY_NAME); } if ((pos = strfind(data, "\"isp\":")) != -1) { pos = pos + 7; strmid(isp, data, pos, strfind(data, "\"", true, pos), MAX_COUNTRY_NAME); } if (pos != -1) { strpack(g_asLookupData[index][e_LookupCountry], country, MAX_COUNTRY_NAME char); strpack(g_asLookupData[index][e_LookupRegion], region, MAX_COUNTRY_NAME char); strpack(g_asLookupData[index][e_LookupCity], city, MAX_COUNTRY_NAME char); strpack(g_asLookupData[index][e_LookupISP], isp, MAX_COUNTRY_NAME char); CallLocalFunction("OnLookupComplete", "dssss", index, country, region, city, isp); } } } return 0; }