commands with two possible parameters
#1

what i am trying to create is very simple, but i noticed i never really got into this specific part, i guess its about time i learned this.

What i want to do is a cmd called "toggle", and depending on the parameter the player use, for example:
/toggle pm, it would toggle the player PM. If he types /toggle stats that would toggle his stats, how can i write it using CMD:command(playerid, params[])?
Reply
#2

pawn Код:
CMD:toggle(playerid, params[])
{
    new options[128];
   
    if(sscanf(params, "s[128]",options))
    {
        SendClientMessage(playerid, COLOR_WHITE, "Usage: /toggle [options]");
        SendClientMessage(playerid, COLOR_SILVER, "OPTIONS: stats | pm");
        return 1;
    }
    else if(!strcmp(options, "stats", true, 5))
    {
        //do stuff here
    }
    else if(!strcmp(options, "pm", true, 5))
    {
        //do stuff here
    }
    else SendClientMessage(playerid, COLOR_RED, "Invalid Option.");
    return 1;
}
Reply
#3

@IceBilizard why bother using sscanf() you don't need it nor an extra variable just use isnull(params) of course.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)