SA-MP Forums Archive
sscanf warning: Format specifier does not match parameter count - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: sscanf warning: Format specifier does not match parameter count (/showthread.php?tid=620094)



sscanf warning: Format specifier does not match parameter count - DTV - 26.10.2016

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.


Re: sscanf warning: Format specifier does not match parameter count - AndySedeyn - 26.10.2016

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



Re: sscanf warning: Format specifier does not match parameter count - DTV - 26.10.2016

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