PDA

View Full Version : data spliting


JeaSon
02/03/2015, 10:03 AM
so far i have done this and it shows only {"as":"AS45595 Pakistan Telecom Company Limited"

the text which im spliting is this its api services ip location

{"as":"AS16276 OVH SAS","city":"Montreal","country":"Canada","countryCode":"CA","isp":"OVH Hosting","lat":45.5078,"lon":-73.5804,"org":"OVH Hosting","query":"167.114.113.176","region":"QC","regionName":"Quebec","status":"success","timezone":"America/Toronto","zip":"H3A"}

IRCCMD:dns(botid, channel[], user[], host[], params[])
{
if(IRC_IsHalfop(botid, channel, user))
{
new id;
if(sscanf(params,"u",id)) return IRC_GroupSay(groupID,"#yrs","Usage: !dns <playerid/playername>");
new str[200],ip[16];
if(IsPlayerConnected(id))
{
GetPlayerIp(id,ip,sizeof ip);
format(str,sizeof str,""HostURL"%s",ip);
HTTP(id, HTTP_GET, str, "", "nSocketReceiveData");
} else IRC_GroupSay(groupID,"#yrs","That player is not connected..");
}
return 1;
}

CMD:dns(playerid,params[])
{

new id;
if(sscanf(params,"u",id)) return SendClientMessage(playerid,0xFF0000AA,"Usage: !dns <playerid/playername>");
new str[200],ip[16];
if(IsPlayerConnected(id))
{
GetPlayerIp(id,ip,sizeof ip);
format(str,sizeof str,""HostURL"%s",ip);
HTTP(playerid, HTTP_GET, str, "", "nSocketReceiveData");
} else SendClientMessage(playerid,0xFF0000AA,"That player is not connected..");

return 1;
}
forward IRCOnHostResponse(iIndex, response_code, data[]);
public IRCOnHostResponse(iIndex, response_code, data[])
{
new _@str[500];
if(response_code == 200)
{
new geoarray[14][50];
split(data,geoarray,',');
format(_@str,sizeof _@str,"%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s",geoarray[0],geoarray[1],geoarray[2],geoarray[3],geoarray[4],geoarray[5],geoarray[6],geoarray[7],geoarray[8],geoarray[9],geoarray[10],geoarray[11],geoarray[12]);
IRC_GroupSay(groupID,"#yrs", _@str);
}
else
{
format(_@str, sizeof(_@str), "Can't send your request. {C21F1F}Response_Code: %i", response_code);
IRC_GroupSay(groupID,"#yrs", _@str);
}
}

forward OnHostResponse(iIndex, response_code, data[]);
public OnHostResponse(iIndex, response_code, data[])
{
new _@str[250];
if(response_code == 200)
{
new geoarray[14][60];
split(data,geoarray,',');
format(_@str,sizeof _@str,"%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s",geoarray[0],geoarray[1],geoarray[2],geoarray[3],geoarray[4],geoarray[5],geoarray[6],geoarray[7],geoarray[8],geoarray[9],geoarray[10],geoarray[11],geoarray[12]);
SendClientMessage(iIndex, 0xE0E494FF, _@str);



}
else
{
format(_@str, sizeof(_@str), "Can't send your request. {C21F1F}Response_Code: %i", response_code);
SendClientMessage(iIndex, -1, _@str);
}

}

what i want is ( Country: %s | City: %s) new City[32], country[32];

Vince
02/03/2015, 10:31 AM
Looks to be a JSON string. Isn't there an include or a plugin or something that can parse this info?

JeaSon
02/03/2015, 10:35 AM
yes there is sampjson pluging by king_hual but idk how to use it can you give examples