SA-MP Forums Archive
Split - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Split (/showthread.php?tid=186355)



Split - Typhome - 28.10.2010

How do slipt string like:

string = [EU]AUD398

Then will slipting to "[EU] AUD 398".


Re: Split - The_Moddler - 28.10.2010

You can use SSCANF for that, there isn't any other way I think..

Код:
This forum requires that you wait 120 seconds between posts. Please try again in 84 seconds. ...



Re: Split - Typhome - 28.10.2010

it was stock split or what..


Re: Split - randomkid88 - 28.10.2010

split requires a character to judge and split, for example if you had [Eu],AUD,398, you could use split and use the comma as the reference. Since there is no comma, /, ; , :, or anything else, you need to use sscanf. Search for it.


Re: Split - i514x - 28.10.2010

pawn Код:
stock split(const string[], string1[], string2[], character, maxsize = strlen(string)+1)
{
    format(string1, maxsize, "%s", string);
    format(string2, maxsize, "%s", string);
    strdel(string1, character+1, strlen(string));
    strdel(string2, 0, character+1);
    return 1;
}
here you go, tested


Re: Split - Typhome - 28.10.2010

Ok, i do use then AUD;398

I want it slipting to "AUD 398" without that ;

BUT how i do split??

wawa...

new string[256];
string = CarInfo[h][cPlate];
split(string); ??

// Oh i didnt see, i try now.


Re: Split - i514x - 28.10.2010

what do you mean? use it like that:

pawn Код:
new string1[3]; //max length (3)
new string1[3]; //max length (3)
split("AUD398", string1, string2, 3);
4th parameter in split function is the after what character it should be split
and now you have two strings string1 and string2
on string1 you have AUD, on string2 you have 398


Re: Split - Typhome - 28.10.2010

Код:
new string1[4]; //max length (4)
new string1[3]; //max length (3)
new string1[3]; //max length (3)
split("[EU]AUD398", string1, string2, string3, 3);
Then?

Like..

Код:
new string1[4]; //max length (4)
new string1[3]; //max length (3)
new string1[3]; //max length (3)
split(CarInfo[h][cPlate], string1, string2, string3, 3); // ex "[EU]AUD398"
SendClientMessage(playerid, COLOR, CarInfo[h][cPlate]); // splitted
Oh.. i then use "AUD398" without [EU] etc..


Re: Split - i514x - 28.10.2010

yes accept that i did it only that a string can be split into 2 parts so the best thing to do is to split some string one, and then one again


Re: Split - randomkid88 - 28.10.2010

Quote:
Originally Posted by i514x_
Посмотреть сообщение
yes accept that i did it only that a string can be split into 2 parts so the best thing to do is to split some string one, and then one again
Or use sscanf.