This is an easy way to token for a group secluded by whitespaces.
Example:
StrToken("Hello, this is a test.",3,out,24);
out will end up being "is".
Code:
public OnPluginStart()
{
new String:test[]="Hello, this is a test string.";
new String:out[]="";
StrToken(test,5,out,192);
PrintToServer("%s",out);
}
stock StrToken(const String:inputstr[],tokennum,String:outputstr[],maxlen)
{
new String:buf[maxlen+1];
new cur_idx;
new idx;
new curind;
idx=StrBreak(inputstr,buf,maxlen);
if(tokennum==1)
{
strcopy(outputstr,maxlen,buf);
return;
}
curind=1;
while (idx!=-1)
{
cur_idx+=idx;
idx=StrBreak(inputstr[cur_idx],buf,maxlen);
curind++;
if(tokennum==curind)
{
strcopy(outputstr,maxlen,buf);
break;
}
}
}