Sscanf problem
#1

Hey guys,

I got a problem with Sscanf. I've made a dialog, where you can transfer money from one bank account, to another. Used sscanf with this, but im getting a "error line" in my console if i type "1 500", 1 = playerid, 500 = amount.
Error line:
Код:
sscanf warning: Format specifier does not match parameter count.
Code:
pawn Код:
if(dialogid == TRANSFERBB)
    {
        if(response)
        {
            new target[MAX_PLAYER_NAME], cast[MAX_PLAYER_NAME], string[128], string1[128], file[128], file1[128];
            if(!strlen(inputtext)) return SendClientMessage(playerid, SKY_BLUE, " ** playerid amount") && TransferBB
            if(strlen(inputtext))
            {
                new TargetID, Amount;
                if(!sscanf(inputtext, "ui(50)", TargetID, Amount))
                {
                    GetPlayerName(playerid, cast, sizeof cast); GetPlayerName(TargetID, target, sizeof target);
                    format(file, sizeof file, Bankfile, target); format(file1, sizeof file1, Bankfile, cast);
                    if(TargetID == INVALID_PLAYER_ID) return SendClientMessage(playerid, SKY_BLUE, " ** Invalid playerid! ") && TransferBB
                    if(TargetID == playerid) return SendClientMessage(playerid, SKY_BLUE, " ** You can't send money to your own bank account! ") && TransferBB
                    if(Amount > dini_Int(file1, "Cash amount")) return SendClientMessage(playerid, SKY_BLUE, " ** You do not have that amount of money on your bank account! ") && TransferBB
                    if(Amount < dini_Int(file1, "Cash amount"))
                    {
                        printf("%s transfered some cash", cast);
                        dini_IntSet(file1, "Cash amount", dini_Int(file, "Cash amount") - Amount); dini_IntSet(file, "Cash amount", dini_Int(file, "Cash amount") + Amount);
                        format(string, sizeof(string), " ** You transfered $%i to %s his bank account ", Amount, TargetID);
                        format(string1, sizeof(string1), " ** %s transfered $%i to your bank account ", cast, Amount);
                        SendClientMessage(playerid, SKY_BLUE, string); SendClientMessage(TargetID, SKY_BLUE, string1);
                    }
                } else {
                    return SendClientMessage(playerid, SKY_BLUE, " ** playerid amount") && TransferBB
                }
            } else {
                return SendClientMessage(playerid, SKY_BLUE, " ** Please fill in something ")&& TransferBB
            }
        }
        else if(!response)
        {
            Bankhome
        }
Also im getting NO errors when compiling

~Wesley
Reply
#2

pawn Код:
if(!sscanf(inputtext, "ui", TargetID, Amount))
Reply
#3

if you want to use the integer as a optional parameter (with the 50 as default), then just use
Код:
if(!sscanf(inputtext, "uI(50)", TargetID, Amount))
the "i" is uppercase: "I". each parameter writen uppercase will turn it into an optional() parameter.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)