Hi. I've maded a stock, but is not working as i expected...is not like "strtok" or something else... E.g i have a string...
Code:
static String[] = "wow | my stock | is working. :D";
i want to extract "my stock" from that string. Here is the stock...
Code:
stock extractstr(Source[], Char1, Char2, RetString[128])
{
new iMaxLen;
iMaxLen = strlen(Source);
new bool:iStarted;
new Len, TempString[256];
Len = formatex(TempString, sizeof TempString - 1, "");
for(new i = 0 ; i < iMaxLen ; i++)
{
if((Source[i] == Char2) && iStarted)
iStarted = false;
if((Source[i] == Char1) && !iStarted)
iStarted = true;
if(iStarted)
{
Len += formatex(TempString[Len], (sizeof TempString - 1) - Len, "%s", Source[i]);
//i think here is the problem, because i must only add one by one char. :/
}
}
trim(TempString);
formatex(RetString, sizeof RetString - 1, "%s", TempString);
}
when i use this...
Code:
public Test(id)
{
static String[] = "wow | my stock | is working. :D";
static TempString[128];
extractstr(String, '|', '|', TempString);
client_print(id, print_chat, "Testing my stock : %s", TempString);
}
currently is printing, "| my stock | wow my is working

....and so on, mixing words :S" ,i want to show only "my stock". If anyone maybe know... :-p
Thanks.
__________________