Multiple Param Commands with SSCANF
#9

Quote:
Originally Posted by Nero_3D
Посмотреть сообщение
If you use sscanf the paramter 's' will get the whole string if no other parameter is passed
That would be the solution stated in the sscanf topic
pawn Код:
if(sscanf(params, "s[128] ", option)) {}
Read above.

I suggest you use y_stringhash it's easier and faster, also not suggesting you to use isnull but it's only a string there's no integer or float so I'd rather use isnull anyways, try this command, make sure sure have #include <YSI\y_stringhash>

pawn Код:
CMD:faction(playerid, params[])
{
    new
        string[ 128 ], pID, rank, msgbox[128];

    if( PlayerInfo[ playerid ][ Faction ] == 0 )
        return SendClientMessage( playerid, COLOR_ADMIN_GM, "You aren't in any faction!" );

    if( isnull( params ) )
        return SendClientMessage( playerid, COLOR_ADMIN_GM, "USAGE: /faction [params]" );

    switch( YHash( params ) )
    {
        case _H< invite >:
        {
            if( sscanf ( params, "u", pID ) )
                return SendClientMessage(playerid, COLOR_ADMIN_GM, "USAGE: /faction invite [Player Name/ID]" );

            if( !IsPlayerConnected( pID ) )
                return SendClientMessage(playerid, COLOR_ADMIN_GM, "Error: 65535 Invalid playerid!" );
           
            print( "Invite" );
            printf( "Debug, 'invite' pID: %s", pID );
           
        }
        case _H< uninvite >:
        {
            if( sscanf( params, "u", pID ) )
                return SendClientMessage( playerid, COLOR_ADMIN_GM, "USAGE: /faction uninvite [Player Name/ID]" );

            if( !IsPlayerConnected( pID ) )
                return SendClientMessage( playerid, COLOR_ADMIN_GM, "Error: 65535 Invalid playerid!" );
           
            print( "Uninvite" );
            printf( "DEBUG 'uninvite' ID: %d", pID );
           
        }
    }  
    return true;
}
Reply


Messages In This Thread
Multiple Param Commands with SSCANF - by FalconWingsX - 17.12.2013, 18:17
Re: Multiple Param Commands with SSCANF - by Joe Staff - 17.12.2013, 18:22
Re: Multiple Param Commands with SSCANF - by FalconWingsX - 17.12.2013, 18:25
Re: Multiple Param Commands with SSCANF - by Hansrutger - 17.12.2013, 18:42
Re: Multiple Param Commands with SSCANF - by FalconWingsX - 17.12.2013, 18:53
Re: Multiple Param Commands with SSCANF - by Hansrutger - 17.12.2013, 19:00
Re: Multiple Param Commands with SSCANF - by FalconWingsX - 19.12.2013, 20:30
AW: Multiple Param Commands with SSCANF - by Nero_3D - 19.12.2013, 21:41
Re: AW: Multiple Param Commands with SSCANF - by Patrick - 19.12.2013, 21:44

Forum Jump:


Users browsing this thread: 2 Guest(s)