Raised This Month: $ Target: $400
 0% 

pawn check if string contains


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-28-2020 , 19:04   Re: pawn check if string contains
Reply With Quote #5

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 ] == '^"' ) );
}
__________________

Last edited by Bugsy; 04-28-2020 at 19:10.
Bugsy 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