sscanf optional params -
Trenico - 02.02.2012
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.
Re: sscanf optional params -
Konstantinos - 02.02.2012
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
Re: sscanf optional params -
Trenico - 02.02.2012
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.
Re: sscanf optional params -
Konstantinos - 02.02.2012
I am not sure but I think "z" it's optional.
Edit: I have just read that the "z" was removed.