Problem with sscanf
#1

pawn Код:
CMD:clan(playerid, params[])
{
    new option[14];
    if (sscanf(params, "s[14]", option))
    {
            return 1; //Dialog is here
    }
    else if (!strcmp(option, "join", true))
    {
            if (sscanf(params,"u", option))
            return SendClientMessage(playerid, -1, "usage: /clan join <clan id>");
    }
        else return 0; // Invalid parameter
        return 1;
}
So if you type /clan join it will show the usage of the command. It doesn't work when I type /clan join 1 etc, can't even see the usage and it returns the invalid parameter.
Reply
#2

pawn Код:
if(sscanf(params, "s[14]D(-1)", option,clanid))
then
pawn Код:
if(clanid < 0) return SendClientMessage(playerid, -1, "usage: /clan join <clan id>");
Reply
#3

There is another problem now.

pawn Код:
CMD:clan(playerid, params[])
{
    new option[14], clanid, id;
    if (sscanf(params, "s[14]D(-1)", option, clanid))
    {
            return 1; //Dialog is here
    }
    else if (!strcmp(option, "join", true))
    {
            if(clanid < 0) return SendClientMessage(playerid, -1, "usage: /clan join <clan id>");
    }
        else if (!strcmp(option, "accept", true))
    {
            if (sscanf(params, "U(-1)", id)) SendClientMessage(playerid, -1, "usage: /clan accept <id>");
           else if (id == INVALID_PLAYER_ID) return SendErrorMessage(playerid, "player not found");
    }
        else return 0; // Invalid parameter
        return 1;
}
So there is another problem. I tried to do the same with join as with accept adding U(-1) but it doesn't work. Any ideas?
Reply
#4

pawn Код:
CMD:clan(playerid, params[])
{
    if(isnull(params))
    {
        return 1; //Dialog is here
    }

    if (!strcmp(params, "join", true, 4))
    {
        if(!params[4] || !('0' <= params[5] <= '9')) return SendClientMessage(playerid, -1, "usage: /clan join <clan id>");
        new clanid = strval(params[5]);
    }
    else if (!strcmp(params, "accept", true, 6))
    {
        new id;
        if (!params[6] || sscanf(params[7], "u", id)) SendClientMessage(playerid, -1, "usage: /clan accept <id>");
        else if (id == INVALID_PLAYER_ID) SendErrorMessage(playerid, "player not found");
        else{
        }
    }
    else return 0; // Invalid parameter

    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)