SA-MP Forums Archive
strins - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: strins (/showthread.php?tid=513288)



strins - Mic_H - 15.05.2014

Sorry if its a foolish mistake..
Код:
public Response(index, response_code, data[])
{
    if(response_code == 200)
    {
        if(data[0]=='s')
        {
            new NILLV[6]= "NoInf";
            for(new i=0; i<=strlen(data); i++)
	    {
		    if(data[i]==','&&data[i+1]==',')
		    {
		        printf("%i", i);
			strins(data,NILLV,i,strlen(data)+9);//stops Here
		    }
	     }
              print(data);
         }
     }
}



Re: strins - BroZeus - 15.05.2014

what are u using this code for
if u can explain then maybe we can make another non-buggy one


Re: strins - Mic_H - 15.05.2014

I am using it to get the country name from a site.. Using HTTP..
Sometimes it doesnt send any value and the value become
"United States, BlablaBla,,,,IP"
"Country, State, Code, Longitude, Lattitude, IP"
So, I want to edit it to : "United States, Blablabla, No Info, No Info, No Info, IP"


Re: strins - Konstantinos - 15.05.2014

You can use strmid to extract the name. You'll need to know at what position the country's name starts and ends though (that depends on the data of the callback).


Re: strins - Mic_H - 15.05.2014

I want to add the Details.. I dont want to remove anything from that.


Re: strins - Mic_H - 15.05.2014

Cux I am using sscanf to extract the details.. Which seems to be working fine but when 4" , "s come together, it seems to fail..


Re: strins - Mic_H - 16.05.2014

For anyone who might come accross like this thing in future. This is how I fixed it. rep+ for both who tried to help.. Much love
Код:
            for(new i=0; i<=14; i++)
			{
			    if(strfind(data, ",,",true)!=-1)
			    {
			        s_Cnt=strfind(data, ",,",true);
			        new S_Size;
					S_Size=strlen(data)+10;
					new MSG_Splitter[200];
					strmid(MSG_Splitter, data, 0, s_Cnt+1);
					strdel(data, 0, s_Cnt+1);
					format(data, S_Size, "%sNo_Info%s", MSG_Splitter, data);
				}
			}