sscanf warning: Format specifier does not match parameter count
#1

I've ran into an issue where this warning shows up with a command.

pawn Код:
CMD:inventory(playerid,params[])
{
    new choice[6],slot;
    if(isnull(params)) return SCM(playerid,COLOR_GREY,"Command Usage: /i(nventory) [info|use|move|give|split|drop]");
    sscanf(params,"s[6]i,",choice,slot);
    //code here
    else if(!strcmp(choice,"drop",true))
    {
        new amount;
        if(sscanf(params,"s[6]iI(1)",choice,slot,amount)) return SCM(playerid,COLOR_GREY,"Command usage: /i(nventory) drop [slotid] [optional:amount]");
        switch(slot)
        {
            case 1..20:
            {
                if(IsInventorySlotEmpty(playerid,slot-1)) return SCM(playerid,COLOR_GREY,"That slot is empty.");
                DropItem(playerid,slot-1,amount);
            }
            default: { SCM(playerid,COLOR_GREY,"That is an invalid slot."); return 1; }
        }
    }
    else return SCM(playerid,COLOR_GREY,"Command Usage: /i(nventory) [info|use|move|give|split|drop]");
    return 1;
}
When I use the command, it performs like it's suppose to, it's just that warning shows up in the server logs.
Reply
#2

You have an extra comma in the second sscanf argument:
PHP код:
"s[6]i" 
Reply
#3

Damn, I didn't notice that. Thanks for pointing that out :P
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)