Raised This Month: $51 Target: $400
 12% 

pawn check if string contains


Post New Thread Reply   
 
Thread Tools Display Modes
PredatorBlock
AlliedModders Donor
Join Date: Apr 2020
Old 04-30-2020 , 07:10   Re: pawn check if string contains
Reply With Quote #21

Code:
        new reason[ 70 ];
	read_argv( 3, reason, sizeof ( reason ) -1 );

        LogBan( "* Ban Reason: %s", reason );
Is it already to 70.
If reason is without quotes it show only part from it never full... only if reason is between "" then it show full.

Look i do a test:
amx_ban Nickname 5 Testing long message! Testing long message! Testing long message!

RESULT:
Ban Reason: Testing

Thank you

Last edited by PredatorBlock; 04-30-2020 at 07:20.
PredatorBlock is offline
PredatorBlock
AlliedModders Donor
Join Date: Apr 2020
Old 04-30-2020 , 21:51   Re: pawn check if string contains
Reply With Quote #22

@Bugsy

I just find a problem!

If i type reason with spaces between quotes it returns Proper usage of command....
Example: amx_ban "STEAM..." 5 "Reason with spaces does not work"

Thank you.
PredatorBlock is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-30-2020 , 22:47   Re: pawn check if string contains
Reply With Quote #23

Show your code.
__________________
Bugsy is offline
PredatorBlock
AlliedModders Donor
Join Date: Apr 2020
Old 04-30-2020 , 23:55   Re: pawn check if string contains
Reply With Quote #24

Also please take a look here... if you can help me to fix 2 bugs...

https://forums.alliedmods.net/showthread.php?t=317769


Code:
        /* ======== START FORCE ARGS USING DOUBLE QUOTES ======== */     new szArgs[ 2 ][ 33 ] , iNumArgs;     iNumArgs = GetArgs( szArgs , sizeof( szArgs ) , charsmax( szArgs[] ) );         if ( iNumArgs != 2 )     {         console_print( id , "Proper usage of command is: amx_kick <name, #userid> ^"reason^"" );         return PLUGIN_HANDLED;     }     else     {         /*         //Require all args in quotes         for ( new i = 0 ; i < iNumArgs ; i++ )         {             if ( ( szArgs[ i ][ 0 ] != '^"' ) && ( szArgs[ i ][ strlen( szArgs[ i ] ) - 1 ] != '^"' ) )             {                 console_print( id , "Proper usage of command is: amx_kick <name, #userid> ^"reason^"" );                 return PLUGIN_HANDLED;             }         }         */                 //Require only 2rd arg in quotes         if ( ( szArgs[ 1 ][ 0 ] != '^"' ) && ( szArgs[ 1 ][ strlen( szArgs[ 1 ] ) - 1 ] != '^"' ) )         {                 console_print( id , "Proper usage of command is: amx_kick <name, #userid> ^"reason^"" );                 return PLUGIN_HANDLED;         }                 /*         //Require 1st and 2rd arg in quotes         if ( ( szArgs[ 0 ][ 0 ] != '^"' ) && ( szArgs[ 0 ][ strlen( szArgs[ 0 ] ) - 1 ] != '^"' ) )         {                 console_print( id , "Proper usage of command is: amx_kick <name, #userid> ^"reason^"" );                 return PLUGIN_HANDLED;         }         if ( ( szArgs[ 1 ][ 0 ] != '^"' ) && ( szArgs[ 1 ][ strlen( szArgs[ 1 ] ) - 1 ] != '^"' ) )         {                 console_print( id , "Proper usage of command is: amx_kick <name, #userid> ^"reason^"" );                 return PLUGIN_HANDLED;         }         */                 /*         //Require 1st and 3rd arg in quotes         if ( ( szArgs[ 0 ][ 0 ] != '^"' ) && ( szArgs[ 0 ][ strlen( szArgs[ 0 ] ) - 1 ] != '^"' ) )         {                 console_print( id , "Proper usage of command is: amx_kick <name, #userid> ^"reason^"" );                 return PLUGIN_HANDLED;         }         if ( ( szArgs[ 2 ][ 0 ] != '^"' ) && ( szArgs[ 2 ][ strlen( szArgs[ 2 ] ) - 1 ] != '^"' ) )         {                 console_print( id , "Proper usage of command is: amx_kick <name, #userid> ^"reason^"" );                 return PLUGIN_HANDLED;         }         */     }     /* ======== END FORCE ARGS USING DOUBLE QUOTES ======== */

Last edited by PredatorBlock; 04-30-2020 at 23:56.
PredatorBlock is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-01-2020 , 00:02   Re: pawn check if string contains
Reply With Quote #25

Show me the command that tells you its not working correctly
__________________
Bugsy is offline
PredatorBlock
AlliedModders Donor
Join Date: Apr 2020
Old 05-01-2020 , 09:56   Re: pawn check if string contains
Reply With Quote #26

Quote:
Originally Posted by Bugsy View Post
Show me the command that tells you its not working correctly
This is the line where cannot pass:

Code:
    if ( iNumArgs != 2 )     {         console_print( id , "Proper usage of command is: amx_slay <name, #userid> ^"reason^"" );         return PLUGIN_HANDLED;     }

I debug like this:
console_print( id , "Count args: %d", iNumArgs );

command: amx_kick Nickname "This is testing reason"
result: Count args: 5

It's counting also spaces inside quotes!

So i change only this and is working: if ( iNumArgs < 2 )

I think you should change to not counting spaces as args inside quotes on your code! i don't know how to do it
Code:
GetArgs( szArgs[][] , iSize , iLen ) {     new szText[ 128 ] , iSourceLen , iPos , bool:bInArg , iArgIndex , iArgPos;         iSourceLen = read_args( szText , charsmax( szText ) );         while ( ( iPos < iSourceLen ) && ( iArgIndex < iSize ) )     {         if ( !bInArg && szText[ iPos ] != ' ' )             bInArg = true;                 if ( szText[ iPos ] != ' ' )         {             szArgs[ iArgIndex ][ iArgPos++ ] = szText[ iPos ];                         if ( iArgPos >= iLen )             {                                        while ( ( iPos < iSourceLen ) && szText[ ++iPos ] != ' ' )                 {}                                 bInArg = false;                 iArgIndex++;                 iArgPos = 0;             }         }         else if ( bInArg && ( szText[ iPos ] == ' ' ) )         {             bInArg = false;             iArgIndex++;             iArgPos = 0;         }                 iPos++;     }         return ( iArgIndex + 1 ); }

Last edited by PredatorBlock; 05-01-2020 at 09:59.
PredatorBlock 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 06:58.


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