Raised This Month: $ Target: $400
 0% 

Something like SplitString


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
eyal282
Veteran Member
Join Date: Aug 2011
Old 01-29-2018 , 09:20   Something like SplitString
Reply With Quote #1

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
eyal282 is offline
Reiko1231
Member
Join Date: Apr 2013
Location: Russia
Old 01-29-2018 , 10:56   Re: Something like SplitString
Reply With Quote #2

You can try ExplodeString
Reiko1231 is offline
eyal282
Veteran Member
Join Date: Aug 2011
Old 01-29-2018 , 13:33   Re: Something like SplitString
Reply With Quote #3

Quote:
Originally Posted by Reiko1231 View Post
You can try ExplodeString
The size of the array is yet to be known, not good.
__________________
I am available to make plugins for pay.

Discord: Eyal282#1334
eyal282 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 17:22.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode