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-29-2020 , 19:04   Re: pawn check if string contains
Reply With Quote #10

This will get the full argument, including the quotes. There may be a native that I don't know about that does this. Not thoroughly tested.

Input: amx_test "123" 456 "789" "1"

Output:
Code:
4 args
Arg[0]="123"
Arg[1]=456
Arg[2]="789"
Arg[3]="1"
PHP Code:
#include <amxmodx>

public plugin_init() 
{
    
register_concmd"amx_test" "Test" );
}

public 
Testid )
{
    new 
szArgs10 ][ 32 ];
    
    new 
iNumArgs GetArgsszArgs sizeofszArgs ) , charsmaxszArgs[] ) );
    
    
server_print"%d args" iNumArgs );
    
    for ( new 
iNumArgs i++ )
    {
        
server_print"Arg[%d]=%s" szArgs] );
    }
}
    
GetArgsszArgs[][] , iSize iLen )
{
    new 
szText128 ] , iSourceLen iPos bool:bInArg iArgIndex iArgPos;
    
    
iSourceLen read_argsszText charsmaxszText ) );
    
    while ( ( 
iPos iSourceLen ) && ( iArgIndex iSize ) )
    {
        if ( !
bInArg && szTextiPos ] != ' ' )
            
bInArg true;
        
        if ( 
szTextiPos ] != ' ' )
        {
            
szArgsiArgIndex ][ iArgPos++ ] = szTextiPos ];
            
            if ( 
iArgPos >= iLen )
            {    
                    
                while ( ( 
iPos iSourceLen ) && szText[ ++iPos ] != ' ' )
                {}
                
                
bInArg false;
                
iArgIndex++;
                
iArgPos 0;
            }
        }
        else if ( 
bInArg && ( szTextiPos ] == ' ' ) )
        {
            
bInArg false;
            
iArgIndex++;
            
iArgPos 0;
        }
        
        
iPos++;
    }
    
    return ( 
iArgIndex );

__________________
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