sscanf optional params
#1

I have made a cmd wich edits different stuff from a team/faction, but it's the first time i use optional params in sscanf, and the cmd doesnt work well, here is the code:

pawn Code:
cmd(editarfaccion,playerid,params[])
{
    new opcs[30],id,opcd,opc[30];
    new string[80];
    if (GetPVarInt(playerid,"Logueado"))
    {
        if (InfoJugador[playerid][jAdmin] >= 11)
        {
            if (!sscanf(params,"ds[30]S(-1)[30]D(-1)",id,opc,opcs,opcd))
            {
                if(id < 0 || id > TOTAL_FACCIONES) return Mensaje(playerid,color_gris,"Nъmero de facciуn invalida!");
                if (!strcmp(opc,"nombre",true))
                {
                    if (!strlen(opcs))
                    {
                        format(string,sizeof(string),"Info: {ffffff}Usa /editarfaccion %d nombre [nuevo nombre]",id);
                        Mensaje(playerid,color_amarillo,string);
                        return 1;
                    }
                    if(strlen(opcs) > 30 || strlen(opcs) < 3) return Mensaje(playerid,color_gris,"El nombre de la facciуn no debe tener mбs de 30 caracteres o menos de 3.");
                    InfoFaccion[id][faccNombre] = opcs;
                    GuardarFaccion(id);
                }
                else
                {
                    format(string,sizeof(string),"Info: {ffffff}Usa /editarfaccion %d [opciуn]",id);
                    Mensaje(playerid,color_amarillo,string);
                    return 1;
                }
            }
            else
            {
                Mensaje(playerid,color_amarillo,"Info: {ffffff}Usa /editarfaccion [id] [opciуn]");
                Mensaje(playerid,color_amarillo,"||____________Opciones____________||");
                Mensaje(playerid,color_blanco,"  Nombre");
            }
        }
        else Mensaje(playerid,color_rojo,NOADM);
    }
    else Mensaje(playerid,color_gris,NOLOG);
    return 1;
}
It just doesnt work, if someone know how to make a cmd with optional params with sscanf, please tell me.
Reply
#2

pawn Code:
"ds[30]S(-1)[30]D(-1)",id,opc,opcs,opcd
use "r" for id and if the opc, opcs and opcd are string then use "s[ value ]"
For Example:
pawn Code:
new
    id, opc[ 30 ], opcs[ 30 ], opcd[ 30 ];

if( !sscanf( params, "rs[30]s[30]s[30]", id, opc, opcs, opcd ) )
{
    // Rest
Reply
#3

Yes i know but i want that opcs and opcd be optional that's why i put the S and D capital, and the -1 is not specified, so that makes them optional, and the id is just a normal id not a player's one, that's why i pt the d.
Reply
#4

I am not sure but I think "z" it's optional.

Edit: I have just read that the "z" was removed.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)