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=548047)



sscanf warning: Format specifier does not match parameter count. - Baltimore - 27.11.2014

Hello !

I have this warning, with this code:

pawn Код:
COMMAND:give(playerid, params[])
{
    new id,
        action[36],
        string[144],
        qty;
   
    if(sscanf(params, "s[36]", action))
    {
        return SendClientMessage(playerid, -1, "Usage: /give <item> <id> <qty>");
    }
   
    if(!strcmp(action, "test", true, 4))
    {
        if(sscanf(params, "s[36]ud", action, id, quantite))
        {
            return SendClientMessage(playerid, -1, "Usage: /give test <id> <qty>");
        }
    }
    return 1;
}
Thx!


Re : sscanf warning: Format specifier does not match parameter count. - Dutheil - 27.11.2014

You can to do like that :
pawn Код:
COMMAND:give(playerid, params[])
{    
    if(isnull(params)) return SendClientMessage(playerid, -1, "Usage: /give <item> <id> <qty>");
   
    new
        id,
        qty;

    if(strcmp(params, "test", true, 4) == 0)
    {
        if(sscanf(params, "'test 'ud", id, qty)) return SendClientMessage(playerid, -1, "Usage: /give test <id> <qty>");
       
        // actions
    }
   
    else if(strcmp(params, "autre", true, 5) == 0)
    {
        if(sscanf(params, "'autre 'ud", id, qty)) return SendClientMessage(playerid, -1, "Usage: /give autre <id> <qty>");
       
        // actions
    }
   
    return SendClientMessage(playerid, -1, "Item list : dsfsdfsdf");
}