Multiple Parameter Commands
#1

I've got a command called /edit, I'm trying to get this to work, and unfortunately, it's just not turning out to be as simple as I thought it'd be, can't get it to work, and I always have this issue. Think anyone could help me out, and figure out what I'm doing wrong? Thanks in advance guys.

pawn Код:
CMD:edit(playerid, params[])
{
    // Command errors
    #define INV_NAME SendClientMessage(playerid, -1, "Invalid 'name' parameter!")
   
    if(isnull(params))
    {
        SendClientMessage(playerid, -1, "/edit [name]");
        SendClientMessage(playerid, -1, " Available Names: 'faccfg', 'faction', 'player'");
        return 1;
    }
   
    new
        pname[50];
       
    if(!sscanf(params, "s[50]", pname))
    {
        if(!strcmp(pname, "faccfg"))
        {
            new
                action[25];
               
            if(sscanf(params, "s[25]", action))
            {
                SendClientMessage(playerid, -1, "/edit factionconfig [action]");
                SendClientMessage(playerid, -1, " Available Actions: 'chatcol', 'usenametags', 'nametagcol'");
                return 1;
            }
           
            if(!strcmp(action, "chatcol"))
            {
                new
                    col[15];
                   
                if(sscanf(params, "s[15]", col))
                    return SendClientMessage(playerid, -1, "/edit factionconfig chatcol [hex color]");
                   
                FactionConfig[ChatCol] = col;
                SaveFactionConfigFile();
                return 1;
            }
        }
        else if(!strcmp(pname, "faction"))
        {
            new
                fid,
                action[25];
               
            if(sscanf(params, "is[25]", fid, action))
            {
                SendClientMessage(playerid, -1, "/edit faction [faction id] [action]");
                SendClientMessage(playerid, -1, " Available Actions: 'name'");
                return 1;
            }
        }
        else if(!strcmp(pname, "player"))
        {
            SendClientMessage(playerid, -1, "editing a player!");
        }
        else return INV_NAME;
    }
   
    #undef INV_NAME
    return 1;
}
Reply
#2

Try
pawn Код:
if(sscanf(params[strlen("faccfg")], "s[25]", action)) //or if(sscanf(params, "{s[10]}s[25]", action))
{
    SendClientMessage(playerid, -1, "/edit factionconfig [action]");
    SendClientMessage(playerid, -1, " Available Actions: 'chatcol', 'usenametags', 'nametagcol'");
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)