Question

Добрый вечер , использую инклуд для определения информации об ип. 
 

Спойлер

// Сам инклуд 
#if defined _player_geolocation_included
    #endinput
#endif
#define _player_geolocation_included
 
#if !defined _samp_included
    #error Please include <a_samp> first.
#endif
 
#if !defined HTTP
    #error Please include <a_http> first.
#endif
 
#if !defined sscanf
    #error Please include <sscanf2> first.
#endif
 
#define GEO_IP_INFO_DETECT_URL          "ip-api.com/csv/"
#define GEO_IP_INFO_DETECT_URL_FIELDS   "?fields=721887"
 
#define GEO_MAX_IP_LENGTH               (16 + 1)
#define GEO_MAX_COUNTRY_CODE_LENGTH     (4 + 1)
#define GEO_MAX_COUNTRY_NAME_LENGTH     (32 + 1)
#define GEO_MAX_REGION_CODE_LENGTH      (6 + 1)
#define GEO_MAX_REGION_NAME_LENGTH      (32 + 1)
#define GEO_MAX_CITY_NAME_LENGTH        (32 + 1)
#define GEO_MAX_DISTRICT_NAME_LENGTH    (64 + 1)
#define GEO_MAX_LAT_LON_LENGTH          (12 + 1)
#define GEO_MAX_TIMEZONE_NAME_LENGTH    (64 + 1)
#define GEO_MAX_PROVIDER_NAME_LENGTH    (32 + 1)
#define GEO_MAX_MOBILE_STATUS_LENGTH    (5 + 1)
#define GEO_MAX_PROXY_LENGTH            (5 + 1)
 
enum e_PLAYER_GEO_INFO
{
    player_country_code[GEO_MAX_COUNTRY_CODE_LENGTH],
    player_country[GEO_MAX_COUNTRY_NAME_LENGTH],
    player_region_code[GEO_MAX_REGION_CODE_LENGTH],
    player_region[GEO_MAX_REGION_NAME_LENGTH],
    player_district[GEO_MAX_DISTRICT_NAME_LENGTH],
    player_city[GEO_MAX_CITY_NAME_LENGTH],
    player_lat[GEO_MAX_LAT_LON_LENGTH],
    player_lon[GEO_MAX_LAT_LON_LENGTH],
    player_timezone[GEO_MAX_TIMEZONE_NAME_LENGTH],
    player_provider[GEO_MAX_PROVIDER_NAME_LENGTH],
    player_mobile_status[GEO_MAX_MOBILE_STATUS_LENGTH],
    player_proxy[GEO_MAX_PROXY_LENGTH]
};
new
    player_geo_none[e_PLAYER_GEO_INFO] = 
    {
        "None",
        "None",
        "None",
        "None",
        "None",
        "None",
        "None",
        "None",
        "None",
        "None",
        "None",
        "None"
    },
    player_geo[MAX_PLAYERS][e_PLAYER_GEO_INFO],
    player_geo_ip[MAX_PLAYERS][GEO_MAX_IP_LENGTH];
 
#define GetPlayerIpCountryCode(%0)      player_geo[%0][player_country_code]
#define GetPlayerIpCountry(%0)          player_geo[%0][player_country]
#define GetPlayerIpRegionCode(%0)       player_geo[%0][player_region_code]
#define GetPlayerIpRegion(%0)           player_geo[%0][player_region]
#define GetPlayerIpCity(%0)             player_geo[%0][player_city]
#define GetPlayerIpDistrict(%0)         player_geo[%0][player_district]
#define GetPlayerIpLatitude(%0)         player_geo[%0][player_lat]
#define GetPlayerIpLongtitude(%0)       player_geo[%0][player_lon]
#define GetPlayerIpTimeZone(%0)         player_geo[%0][player_timezone]
#define GetPlayerIpProvider(%0)         player_geo[%0][player_provider]
#define GetPlayerIpMobileStatus(%0)     player_geo[%0][player_mobile_status]
#define GetPlayerIpProxyStatus(%0)      player_geo[%0][player_proxy]
 
#define GetPlayerIpLat(%0)              GetPlayerIpLatitude(%0)
#define GetPlayerIpLon(%0)              GetPlayerIpLongtitude(%0)
 
public OnPlayerConnect(playerid)
{
    GetPlayerIp(playerid, player_geo_ip[playerid], GEO_MAX_IP_LENGTH);
 
    new 
        request[31 - 2 + GEO_MAX_IP_LENGTH];
 
    strcat(request, GEO_IP_INFO_DETECT_URL);
    strcat(request, player_geo_ip[playerid]);
    strcat(request, GEO_IP_INFO_DETECT_URL_FIELDS);
 
    HTTP(playerid, HTTP_GET, request, "", "p_geo_OnIpInformationRequested");
 
#if defined p_geo_OnPlayerConnect
    p_geo_OnPlayerConnect(playerid);
#endif
    return 1;
}
#if defined _ALS_OnPlayerConnect
    #undef OnPlayerConnect
#else
    #define _ALS_OnPlayerConnect
#endif
#define OnPlayerConnect p_geo_OnPlayerConnect
#if defined p_geo_OnPlayerConnect
forward p_geo_OnPlayerConnect(playerid);
#endif
 
forward p_geo_OnIpInformationRequested(playerid, response_code, data[]);
public p_geo_OnIpInformationRequested(playerid, response_code, data[])
{
    if(response_code == 200)
    {
        sscanf(data, "p<,>s[32]s[3]s[6]s[32]s[32]s[64]s[12]s[12]s[64]s[32]s[5]s[5]",
            player_geo[playerid][player_country],
            player_geo[playerid][player_country_code],
            player_geo[playerid][player_region_code],
            player_geo[playerid][player_region],
            player_geo[playerid][player_city],
            player_geo[playerid][player_district],
            player_geo[playerid][player_lat],
            player_geo[playerid][player_lon],
            player_geo[playerid][player_timezone],
            player_geo[playerid][player_provider],
            player_geo[playerid][player_mobile_status],
            player_geo[playerid][player_proxy]);
    }
    else
    {
        player_geo[playerid] = player_geo_none;
    }
    return 1;
}
 
 
callback: get_callback ( playerid )
{
	new rows ;
	cache_get_row_count ( rows ) ;
	if ( ! rows )
	{
		SendClientMessage ( playerid, -1,"{8b0000}* {FFFFFF}Данный аккаунт не найден в базе данных." ) ;
		return 1 ;
	}
	else
	{
		new gs_name [ MAX_PLAYER_NAME ],
			gs_increment,
			gs_regdate [ 26 ],
			gs_money,
			gs_level,
			gs_regip [ 16 ],
			gs_lastip [ 16 ],
			gs_lastdate [ 16 ],
			gs_donate	;
 
		cache_get_value_name ( 0, "u_name", gs_name, MAX_PLAYER_NAME ) ;
		cache_get_value_name ( 0, "u_ip_registration", gs_regip , MAX_PLAYER_NAME ) ;
		cache_get_value_name ( 0, "u_last_ip", gs_lastip, MAX_PLAYER_NAME ) ;
		cache_get_value_name ( 0, "u_date_registration", gs_regdate, MAX_PLAYER_NAME ) ;
		cache_get_value_name ( 0, "u_last_date", gs_lastdate, MAX_PLAYER_NAME ) ;
 
		cache_get_value_name_int ( 0, "u_id", gs_increment ) ;
		cache_get_value_name_int ( 0, "u_money", gs_money ) ;
		cache_get_value_name_int ( 0, "u_level", gs_level ) ;
		cache_get_value_name_int ( 0, "u_donate", gs_donate ) ;
 
 
		/*new country [ 32 ] , lastcountry [ 32 ] , city [ 32 ] , lastcity [ 32 ] , provider [ 32 ] , lastprovider [ 32 ] ;
		GetPlayerIpCountry(gs_regip, country, sizeof(country));
		GetPlayerIpCountry(gs_lastip, lastcountry, sizeof(lastcountry));
		GetPlayerIpCity(gs_regip, city, sizeof(city));
		GetPlayerIpCity(gs_lastip, lastcity, sizeof(lastcity));
		GetPlayerIpProvider(gs_regip, provider, sizeof(provider));
		GetPlayerIpProvider(gs_lastip, lastprovider, sizeof(lastprovider));*/
 
 
		global_string [ 0 ] = EOS ;
 
		format ( global_string, sizeof ( global_string  ), "{8b0000}Информация о игроке:\n\n{ffffff}Номер аккаунта: {"#cGN"}%d\n\
		{ffffff}Наличные:{"#cGN"} %d\n\
		{ffffff}Уровень:{"#cGN"} %d\n\
		{ffffff}Донат:{"#cGN"} %d\n\n\
		{ffffff}IP адрес(регист.):{"#cGN"} %s\n\
		{ffffff}IP адрес(послед.):{"#cGN"} %s\n\n\
		{ffffff}Дата регистрации:{"#cGN"} %s\n\
		{ffffff}Дата послед. пребывания:{"#cGN"} %s\n\n\
		{8b0000}Техническая информация игрока:\n\n\
		{ffffff}Страна при регистрации:{"#cGN"} %s\n\
		{ffffff}Страна при последнем входе:{"#cGN"} %s\n\
		{ffffff}Город при регистрации:{"#cGN"} %s\n\
		{ffffff}Город при последнем входе:{"#cGN"} %s\n\
		{ffffff}Провайдер при регистрации:{"#cGN"} %s\n\
		{ffffff}Провайдер при последнем входе:{"#cGN"} %s",
		gs_increment, gs_money, gs_level, gs_donate, GetPlayerIpCountry(gs_regip),/* GetPlayerIpCountry(gs_lastip),
		GetPlayerIpCity(gs_regip ), GetPlayerIpCity(gs_lastip), GetPlayerIpProvider(gs_regip), 
		GetPlayerIpProvider(gs_lastip) ,*/ gs_regdate, gs_lastdate ); // error 033: array must be indexed (variable "gs_regip")
 
		new header_string [ MAX_PLAYER_NAME + 9 ] ;
		format ( header_string, sizeof ( header_string  ), "{8b0000}%s", gs_name ) ;
		show_dialog ( playerid, d_none, DIALOG_STYLE_MSGBOX, header_string, global_string, "Закрыть", "" ) ;
	}
	return 1;
}

 

 

Edited by odosenok

Share this post


Link to post

7 answers to this question

  • 0

@Артём Светличный Здравствуйте, а в чем ваш вопрос? Пожалуйста опишите, что вас привело сюда.

Share this post


Link to post
  • 0

Приветствую.

 

В чем, собственно, проблема? Не определяется город, страна, или что?

Если проблема именно в этом, то там нужны специальные базы со странами и городами. Если причина именно в этом, то напишите мне в ВК - vk.com/way.developer

Edited by glvde.

Заметка от Cawfee , создано

А что мешает разрешать вопросы и проблемы в рамках форума?

Share this post


Link to post
  • 0

@Nekit_Krut18 При компиляции мода выдает ошибку  "ошибка 033: массив должен быть проиндексирован (переменная "gs_regip")"
в данной строчке  ( GetPlayerIpCountry (gs_regip) ) 

Share this post


Link to post
  • 0

@Артём Светличный, покажите участок кода, где появилась данная ошибка. Так же, покажите, как у Вас объявлена gs_regip

Share this post


Link to post
  • 0

@odosenok, по сути - уже ничего, а так, пришлось бы кидать ссылки на базы с городами.

Share this post


Link to post
  • 0

@glvde., "базы с городами" находятся в большом секрете?)

Share this post


Link to post
  • 0

@odosenok, ну, не особо) Просто она приватная, может быть, солью когда-нибудь. А то в последнее время я слишком много всего сливаю)

Share this post


Link to post
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • Chopick
      By Chopick
      Всем здравствуйте! Делаю систему домов/бизнесов по туториалу knox know с плагином GoodArea. Есть проблема, если заходишь в интерьер бизнеса, то когда выходишь спавнит почему-то на пикап дома.

      Вот енумы:
       
      #define MAX_HOUSES 1000 #define MAX_BIZS 1000 enum house {         hID,         STREAMER_TAG_PICKUP:hPICKUP,         STREAMER_TAG_AREA:hAREA,         hOWNER[MAX_PLAYER_NAME],         STREAMER_TAG_3D_TEXT_LABEL:hTEXT[256],         STREAMER_TAG_MAP_ICON:hICON,         hPRICE,         hCLASS,         hINTERIOR,         Float:hX,         Float:hY,         Float:hZ,         Float:hA,         hCONDITION // Закрыт/Открыт } new House[MAX_HOUSES][house]; new Houses; new HouseGroup; enum biz {         bID,         STREAMER_TAG_PICKUP:bPICKUP,         STREAMER_TAG_AREA:bAREA,         bOWNER[MAX_PLAYER_NAME],         STREAMER_TAG_3D_TEXT_LABEL:bTEXT[256],         STREAMER_TAG_MAP_ICON:bICON,         bNAME[25],         bPRICE,         bTYPE,         bINTERIOR,         Float:bX,         Float:bY,         Float:bZ,         Float:bA } new Biz[MAX_BIZS][biz]; new Bizs; new BizGroup; enum interior_info {         intID,         intNAME[41],         intINTERIOR,         Float:intX,         Float:intY,         Float:intZ,         Float:intA,         STREAMER_TAG_AREA:intAREA } new Interior[MAX_INTERIORS][interior_info]; new Interiors; new InteriorGroup; Вот что у меня в OnGameModeInit:
      HouseGroup = CreateGroupGoodAreas(GoodArea:HouseEnter); InteriorGroup = CreateGroupGoodAreas(GoodArea:InteriorExit); BizGroup = CreateGroupGoodAreas(GoodArea:BizArea);  
      Вот стоки:
      GAResponse:HouseEnter(playerid, response, key, index) {         switch(response)         {             case GA_RESPONSE_PRESS_KEY:             {                 if(key & KEY_WALK)                 {                 if(House[index][hCONDITION] > 0 && House[index][hOWNER] == player_info[playerid][NAME] || House[index][hCONDITION] == 0)                 {                                         GoToInterior(playerid, House[index][hINTERIOR]);                                         SetPlayerVirtualWorld(playerid, index);                                 }                                 else if(House[index][hCONDITION] > 0 && House[index][hOWNER] != player_info[playerid][NAME]) return SCM(playerid, COLOR_RED, "[Ошибка]{ffffff}Этот дом закрыт на ключ!");                         }                 }                 case GA_RESPONSE_ENTER:                 {                     if(House[index][hOWNER] == 0)                     {                         CreateNoOwnerHouseTD(playerid);                         for(new i = 0; i < sizeof NoOwnerTextDraw_PTD[]; i++)                         {                             PlayerTextDrawShow(playerid, NoOwnerTextDraw_PTD[playerid][i]);                                 }                                 new price[8];                                 format(price, sizeof(price), "%d$", House[index][hPRICE]);                                 PlayerTextDrawSetString(playerid, NoOwnerTextDraw_PTD[playerid][2], price);                                 new id[9];                                 format(id, sizeof(id), "%d", House[index][hID]);                                 PlayerTextDrawSetString(playerid, NoOwnerTextDraw_PTD[playerid][0], id);                                 switch(House[index][hCLASS])                                 {                                     case 1: PlayerTextDrawSetString(playerid, NoOwnerTextDraw_PTD[playerid][1], "A");                                     case 2: PlayerTextDrawSetString(playerid, NoOwnerTextDraw_PTD[playerid][1], "B");                                     case 3: PlayerTextDrawSetString(playerid, NoOwnerTextDraw_PTD[playerid][1], "C");                                 }                                 for(new i = 0; i < sizeof NoOwnerTextDraw_TD; i++)                         {                             TextDrawShowForPlayer(playerid, NoOwnerTextDraw_TD[i]);                                 }                         }                 }                 case GA_RESPONSE_LEAVE:                 {                 for(new i = 0; i < sizeof NoOwnerTextDraw_PTD[]; i++)                 {                     PlayerTextDrawHide(playerid, NoOwnerTextDraw_PTD[playerid][i]);                         }                         for(new i = 0; i < sizeof NoOwnerTextDraw_TD; i++)                 {                     TextDrawHideForPlayer(playerid, NoOwnerTextDraw_TD[i]);                         }                 }         }         return 1; } GAResponse:BizArea(playerid, response, key, index) {         switch(response)         {             case GA_RESPONSE_PRESS_KEY:             {                 if(key & KEY_WALK)                 {                     GoToInteriorBiz(playerid, Biz[index][bINTERIOR]);                                 SetPlayerVirtualWorld(playerid, index);                 }                 }         }         return 1; } GAResponse:InteriorExit(playerid, response, key, index) {         switch(response)         {             case GA_RESPONSE_PRESS_KEY:             {                 new world = GetPlayerVirtualWorld(playerid);                 if(key & KEY_WALK)                 {                     if(world < MAX_HOUSES)                     {                         SetPlayerInterior(playerid, 0);                             SetPlayerVirtualWorld(playerid, 0);                             SetPlayerPos(playerid, House[world][hX], House[world][hY], House[world][hZ]);                             SetPlayerFacingAngle(playerid, House[world][hA]);                                 }                                 else if(world < MAX_HOUSES + MAX_BIZS)                     {                         world -= MAX_HOUSES;                                         printf("%d index world", world);                         SetPlayerInterior(playerid, 0);                             SetPlayerVirtualWorld(playerid, 0);                             SetPlayerPos(playerid, Biz[world][bX], Biz[world][bY], Biz[world][bZ]);                             SetPlayerFacingAngle(playerid, Biz[world][bA]);                                 }                         }                         if(key & KEY_CTRL_BACK)                         {                             if(player_info[playerid][HOUSE] != House[world][hID]) return SCM(playerid, COLOR_RED, "[Ошибка]{ffffff}Вы не владелец данного дома!");                             new dialog[256];                                 format(dialog, sizeof(dialog),                                         "{ffd900}[1]{ffffff}Информация о доме\n\                                         {ffd900}[2]{ffffff}%s дом",                                 (House[world][hCONDITION] == 1) ? ("{00ff00}Открыть") : ("{ff0000}Закрыть"));                             SPD(playerid, DLG_HMENU, DIALOG_STYLE_LIST, "{ffd900}Меню дома", dialog, "Выбрать", "Закрыть");                             return 1;                         }                 }         }         return 1; } stock GoToInterior(playerid, interior) {     for(new i = 0; i < Interiors; i++)         {             if(Interior[i][intID] != interior) continue;             SetPlayerInterior(playerid, Interior[i][intINTERIOR]);             SetPlayerPos(playerid, Interior[i][intX], Interior[i][intY], Interior[i][intZ]);             SetPlayerFacingAngle(playerid, Interior[i][intA]);             SetPlayerCheckpoint(playerid, Interior[i][intX], Interior[i][intY], Interior[i][intZ], 1.0);             new str[128];             format(str, sizeof(str),                         "Нажмите \"ALT\" для выхода\n\                         Нажмите \"H\", чтобы открыть меню дома");             Create3DTextLabel(str, -1, Interior[i][intX], Interior[i][intY], Interior[i][intZ], 15.0, 0, 1);             return 1;         }         return 0; } stock GoToInteriorBiz(playerid, interior) {     for(new i = 0; i < Interiors; i++)         {             if(Interior[i][intID] != interior) continue;             SetPlayerInterior(playerid, Interior[i][intINTERIOR]);             SetPlayerPos(playerid, Interior[i][intX], Interior[i][intY], Interior[i][intZ]);             SetPlayerFacingAngle(playerid, Interior[i][intA]);             SetPlayerCheckpoint(playerid, Interior[i][intX], Interior[i][intY], Interior[i][intZ], 1.0);             new str[128];             format(str, sizeof(str),                         "Нажмите \"ALT\" для выхода");             Create3DTextLabel(str, -1, Interior[i][intX], Interior[i][intY], Interior[i][intZ], 15.0, 0, 1);             return 1;         }         return 0; }  
       
      Что мне делать, подскажите пожалуйста?