More efficient way?
#1

pawn Код:
CMD:command(playerid, params[])
{
    if(sscanf(params, "s[32]", params))
    {
        SendClientMessage(playerid, COLOR_GREY, "USAGE: /command [cmd name]");
    }
    else
    {
        if(!strcmp(params, "help", true))
        {
            SendClientMessage(playerid, COLOR_GREY, "USAGE: /help");

        }
    }
    return 1;
}
I am looking for a more efficient way to make it so if you do /command help (for example) you would be told about the help command. Eventually I add all the commands to this so players can look up what they do.
Reply
#2

Using sscanf isn't really necessary when only using one parameter.
pawn Код:
CMD:command(playerid, params[])
{
    if(isnull(params))
    {
        SendClientMessage(playerid, COLOR_GREY, "USAGE: /command [cmd name]");
    }
   
    if(!strcmp(params, "help", true))
    {
        return SendClientMessage(playerid, COLOR_GREY, "USAGE: /help");
    }
    if(!strcmp(params, "cmd", true))
    {
       // code
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)