SA-MP Forums Archive
How to make a simple command? What am I doing wrong? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: How to make a simple command? What am I doing wrong? (/showthread.php?tid=309028)



How to make a simple command? What am I doing wrong? - Outcast - 06.01.2012

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;
}



Re: How to make a simple command? What am I doing wrong? - Scenario - 06.01.2012

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...


Re: How to make a simple command? What am I doing wrong? - Outcast - 06.01.2012

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


Re: How to make a simple command? What am I doing wrong? - Scenario - 06.01.2012

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!


Re: How to make a simple command? What am I doing wrong? - Outcast - 06.01.2012

Okay, thanks