How to make a simple command? What am I doing wrong?
#1

I want to create a /note command with options add, view, show, delete, give

I know how to make it with ZCMD but I can't make it with the normal commands (OnPlayerCommandTex...)


Can anyone tell me how to make a command with different options?

Here's the code I tried, but it fails, always returns the SendClientMessage(playerid, 0xFFFFFF, "1");

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/note", cmdtext, true) == 0)
    {
        new cmd[5], param[120];
        sscanf(cmdtext, "ss", cmd, param);
       
        if (strcmp("add", param, true, 3) == 0)
        {
            new param1[9], number[1], text[100];
            sscanf(param, "sis", param1, number, text);
           
            if (strcmp("1", number, true) == 0)
            {
                return SendClientMessage(playerid, COLOR_USAGE, "1");
            }
           
            if (strcmp("2", number, true) == 0)
            {
                return SendClientMessage(playerid, COLOR_USAGE, "2");
            }
           
            if (strcmp("3", number, true) == 0)
            {
                return SendClientMessage(playerid, COLOR_USAGE, "3");
            }
           
            if (strcmp("4", number, true) == 0)
            {
                return SendClientMessage(playerid, COLOR_USAGE, "4");
            }
           
            if (strcmp("5", number, true) == 0)
            {
                return SendClientMessage(playerid, COLOR_USAGE, "5");
            }
       
       
        }
       
        if (strcmp("view", param, true) == 0)
        {


        }
       
        if (strcmp("delete", param, true) == 0)
        {


        }
       
        if (strcmp("show", param, true) == 0)
        {


        }
       
        if (strcmp("give", param, true) == 0)
        {


        }
       
        return SendClientMessage(playerid, COLOR_USAGE, "[USAGE:] /note add | view | delete | show | give");

    }
    return 0;
}
Reply
#2

Just make them in ZCMD- believe me it's a LOT easier, way faster, and MUCH more efficient! Plus, you can't use sscanf (at least not that I'm aware) with strcmp commands...
Reply
#3

So, ZCMD is my only option? *Sigh*, wanted to learn it this way :/
Reply
#4

Quote:
Originally Posted by Outcast
Посмотреть сообщение
So, ZCMD is my only option? *Sigh*, wanted to learn it this way :/
It's not your ONLY option, but it's the better option- that or YCMD.

I don't even know/use strcmp for commands, so... don't worry about it!
Reply
#5

Okay, thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)