 |
|
AlliedModders Donor
|

04-28-2020
, 22:38
Re: pawn check if string contains
|
#6
|
Quote:
Originally Posted by Bugsy
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.
|
|
|
|