Split in sa-mp
#1

How to split string to array? Like nospace.
Reply
#2

@belhot1992: You should wrap code in the 'PAWN' BBCode tags.

@OP: You should consider using sscanf to split data, it's generally a lot more faster.
Reply
#3

Код:
forward split(const strsrc[], strdest[][], delimiter);//at the top script
public split(const strsrc[], strdest[][], delimiter)
{
	new i, li;
	new aNum;
	new len;
	while(i <= strlen(strsrc)){
	    if(strsrc[i]==delimiter || i==strlen(strsrc)){
	        len = strmid(strdest[aNum], strsrc, li, i, 128);
	        strdest[aNum][len] = 0;
	        li = i+1;
	        aNum++;
		}
		i++;
	}
	return 1;
}
Reply
#4

Hmm can some explan how i get Pcash to work
pawn Код:
new cash[128];
    new cash2[9][64];
    format(cash,128,"$00000000");
    split2(cash, cash2, '|');
    printf("%d",sizeof(cash2)); // <= i Get 9
    new Pcash3[128];
    format(Pcash3,128,"123");
    new Pcash2[9][64];
    split2(Pcash3, Pcash2, '|');
    printf("%d",sizeof(Pcash2)); // <= i Get 9 to any idea why?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)