I made this stock ( fully functional when RemovePart is true ) that is intended to split a string based on a token, but in a different way than SplitString offers, is there a better method?
if this happens:
Code:
new String:Source[10];
new String:buffer[10];
Format(Source, sizeof(Source), "
SplitString("abc.ndef", ".n", buffer, sizeof(buffer));
then Source becomes "abc" and buffer becomes "def".
The stock if you want:
Code:
// Never tested this stock when RemovePart is set to false.
stock int SpecialSplitString(char[] Source, const char[] part, char[] buffer, int bufferlen, bool:RemovePart = true)
{
new position = SplitString(Source, part, buffer, bufferlen);
if(position == -1)
return -1;
new sourceLength = strlen(Source);
new String:tempSource[sourceLength+2];
Format(tempSource, sourceLength+1, Source);
Format(Source, sourceLength+1, buffer);
ReplaceStringEx(tempSource, sourceLength+1, buffer, "");
if(RemovePart)
ReplaceStringEx(tempSource, sourceLength+1, part, "");
Format(buffer, bufferlen+1, tempSource);
return position;
}
__________________
I am available to make plugins for pay.
Discord: Eyal282#1334