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 , 22:38   Re: pawn check if string contains
Reply With Quote #6

Quote:
Originally Posted by Bugsy View Post
I don't know reg-ex, but this will cover checking that the second arg is wrapped in quotes.
Code:
register_concmd( "amx_test" , "Test" );

public Test( id )
{
	if ( !VerifyArgQuotes() )
	{
		console_print( id , "Proper usage of command is: amx_test <name> ^"Reason^"." );
		return;
	}
	
	//your code    
}
	
bool:VerifyArgQuotes()
{
	new szText[ 128 ] , iPos , iLen;
	
	iLen = read_args( szText , charsmax( szText ) );
	
	if ( szText[ 0 ] == '^"' )
		iPos = strfind( szText , "^"" , .pos = 1 ) + 2;
	else
		iPos = strfind( szText , " " , .pos = 1 ) + 1;
	
	return bool:( iPos && ( szText[ iPos ] == '^"' ) && ( szText[ iLen - 1 ] == '^"' ) );
}

Works like a charm, very good thanks a lot @Bugsy

Last edited by PredatorBlock; 04-28-2020 at 23:05.
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