Raised This Month: $ Target: $400
 0% 

pawn check if string contains


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
PredatorBlock
AlliedModders Donor
Join Date: Apr 2020
Old 04-28-2020 , 11:38   Re: pawn check if string contains
Reply With Quote #4

Hello,

How to make it work with double quotes? "

It won't work both of them.

Code:
new FirstArg[ 32 ], SecondArg[ 32 ];
read_argv( 1, FirstArg, sizeof ( FirstArg ) -1 );
read_argv( 2, SecondArg, sizeof ( SecondArg ) -1 );

if(contain(SecondArg, "^"") == 0 )
{
	console_print(id, "Working...");
}

new Regex:check = regex_match(SecondArg, "^"", ret, error, charsmax(error), "i")

if(Regex:check != REGEX_MATCH_FAIL && Regex:check != REGEX_PATTERN_FAIL && Regex:check != REGEX_NO_MATCH)
{
	console_print(id, "Working...");
}


P.S
Till i got answer i found a solution... i know is not the best but at least it work

	/* === START REASON === */
	new CheckReason[ 100 ];
	read_argv( 2, CheckReason, sizeof ( CheckReason ) -1 );
	
	if( strlen(CheckReason) < 10 )
	{
		console_print(id, "Reason isn't sufficient, please describe more (minimum - 10 chars)");
		return PLUGIN_HANDLED
	}
	
	read_args( CheckReason, charsmax ( CheckReason ) ); //catch charachters
	if( contain( CheckReason, "^"" ) <= 0 )
	{
		console_print(id, "Invalid reason format, please use: amx_kick <name, #userid> ^"reason^"");
		return PLUGIN_HANDLED
	}
	
	// Clean & final reason
	new reason[ 100 ];
	read_argv( 2, reason, sizeof ( reason ) -1 );
	
	/* === END REASON === */


Well what i want to do is to force admin to use command in this way:
amx_kick Nickname "reason_between_quotes"

My solution from beloved it check only if contain at least 1 double_quote

Why i force using ""
Cause if you execute command in this way: amx_kick Nickname You have been kicked from server because you are inactive!

The reason isn't printed fully

If someone can help me to find a simple and clean solution for checking reason argument 2 from kick and force admin to use double quote "" i appreciate.

Thank you

Last edited by PredatorBlock; 04-28-2020 at 14:33.
PredatorBlock is offline
 



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 06:17.


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