Help sscanf2 and optional variables
#1

My idea it Create variable UN with an optional second command. Command left:

pawn Код:
CMD:comando(playerid, params[])
{
    if(sscanf(params, "s[32]I(5)", params[0], params[1]))
    {

        SendClientMessage(playerid, -1, "USO: /comando [Opciуn] ");
        SendClientMessage(playerid, -1, "Primera, Segunda, Tercera, Cuarta");
        return 1;
    }
    if(strcmp(params[0],"primera",true) == 0)
    {
        if(params[1] == 5) return       SendClientMessage(playerid, -1, "/comando  primera [Cantidad]");
        SendClientMessage(playerid, -1, "Crear");
   
    }
    else if(strcmp(params[0],"segunda",true) == 0)
    {

        SendClientMessage(playerid, -1, "segunda");
    }
    else if(strcmp(params[0],"tercera",true) == 0)
    {

    }
    else if(strcmp(params[0],"cuarta",true) == 0)
    {

    }  
    return 1;
}
The idea is that by using / first command will require the second parameter but use / second command no.
I hope I made myself clear.

+1 I solve it.

sorry my bad Inglйs
Reply
#2

Don't reuse the "params" variable. This is prone to all kinds of nasty out-of-bounds errors and other nasty bugs. Create two separate variables and use those. Much cleaner, much less prone to errors.
Reply
#3

Help please.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)