Command
#1

Look. When I apply this cmd(with argument or not), pops up error for bad command. What's wrong?
Код:
if(!strcmp(cmdtext, "/p", true))
{
    new option[7];
    if(sscanf(cmdtext, "s[7]", option)) return SendClientMessage(playerid, -1, "Użyj: /p [szukaj/lista]."); //Usage: /p [find/list]    
if(strcmp(option,"szukaj",true) == 0)
    {
        // code..
    }
    else if(strcmp(option,"lista",true) == 0)
    {
        new dialog[512], item, amount, idx;
        while(GetPlayerItems(playerid, idx, item, amount))
        {
            format(dialog, 512, "%s%d x %s (ID:%d)\n", dialog, amount, GetItemName(item), item);
        }
        ShowPlayerDialog(playerid, DIALOG_ITEMSGUI, DIALOG_STYLE_LIST, "Przedmioty", dialog, "Wybierz", "Zamknij");
    }
    else SendClientMessage(playerid, -1, "Niepoprawna opcja."); //Bad Option
    return 1;
	}

//Down of script
	return ShowPlayerDialog(playerid, DIALOG_CMDBAD, DIALOG_STYLE_MSGBOX, "Błąd!", "Nie ma takiej komendy!", "OK", ""); //Thats pops, this is message if bad cmd
}
Reply
#2

refresh.
optional who can change here strcmp to zcmd, right? have to work.
Reply
#3

Where did you put it? Exactly after OnPlayerCommandText?
If that's on right place, try to change
PHP код:
if(!strcmp(cmdtext"/p"true)) 
to
PHP код:
if(!strcmp(cmd"/p"true)) 
and add at the top of OnPlayerCommandText one
PHP код:
new cmd[64]; 
Reply
#4

For ZCMD:
pawn Код:
CMD:p(playerid, params[])
{
    new option[7];
    if(sscanf(params, "s[7]", option)) return SendClientMessage(playerid, -1, "Użyj: /p [szukaj/lista]."); //Usage: /p [find/list]"); 
    if(strcmp(option,"szukaj",true) == 0)
    {
        // code..
    }
    else if(strcmp(option,"lista",true) == 0)
    {
        new dialog[512], item, amount, idx;
        while(GetPlayerItems(playerid, idx, item, amount))
        {
            format(dialog, 512, "%s%d x %s (ID:%d)\n", dialog, amount, GetItemName(item), item);
        }
        ShowPlayerDialog(playerid, DIALOG_ITEMSGUI, DIALOG_STYLE_LIST, "Przedmioty", dialog, "Wybierz", "Zamknij");
    }
    else SendClientMessage(playerid, -1, "Niepoprawna opcja."); //Bad Option
    return 1;
}
The "bad command" (basically unknown command) is displayed when you type "/p lista"? Maybe, there's something wrong with the stock and cause run time errors. In that case, it returns 0 and the command not found message is being displayed.
Reply
#5

What language is this i don't understand.
Reply
#6

Quote:
Originally Posted by 1FreeHost
Посмотреть сообщение
What language is this i don't understand.
Polish

Translate for you:
Код:
CMD:p(playerid, params[])
{
    new option[7];
    if(sscanf(params, "s[7]", option)) return SendClientMessage(playerid, -1, "Usage: /items [find/list].");
    if(strcmp(option,"find",true) == 0)
    {
        // code..
    }
    else if(strcmp(option,"list",true) == 0)
    {
        new dialog[512], item, amount, idx;
        while(GetPlayerItems(playerid, idx, item, amount))
        {
            format(dialog, 512, "%s%d x %s (ID:%d)\n", dialog, amount, GetItemName(item), item);
        }
        ShowPlayerDialog(playerid, DIALOG_ITEMSGUI, DIALOG_STYLE_LIST, "Items", dialog, "Select", "Close");
    }
    else SendClientMessage(playerid, -1, "Bad option");
    return 1;
}
Reply
#7

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
For ZCMD:
pawn Код:
CMD:p(playerid, params[])
{
    new option[7];
    if(sscanf(params, "s[7]", option)) return SendClientMessage(playerid, -1, "Usage: /items [find/list].");
    if(strcmp(option,"find",true) == 0)
    {
        // code..
    }
    else if(strcmp(option,"list",true) == 0)
    {
        new dialog[512], item, amount, idx;
        while(GetPlayerItems(playerid, idx, item, amount))
        {
            format(dialog, 512, "%s%d x %s (ID:%d)\n", dialog, amount, GetItemName(item), item);
        }
        ShowPlayerDialog(playerid, DIALOG_ITEMSGUI, DIALOG_STYLE_LIST, "Items", dialog, "Select", "Close");
    }
    else SendClientMessage(playerid, -1, "Bad option");
    return 1;
}
The "bad command" (basically unknown command) is displayed when you type "/p lista"? Maybe, there's something wrong with the stock and cause run time errors. In that case, it returns 0 and the command not found message is being displayed.
Commands parameters still not work.
Reply
#8

bump
Reply
#9

Код:
CMD:p(playerid, params[])
{
    new option[7];
    if(sscanf(params, "s[7]", option)) return SendClientMessage(playerid, -1, "Usage: /items [find/list].");
    if(strcmp(option,"find",true) == 0)
    {
        // code..
    }
    else if(strcmp(option,"list",true) == 0)
    {
        new dialog[512], item, amount, idx;
        while(GetPlayerItems(playerid, idx, item, amount)) // CHECK THIS FUNCTION, MAYBE RETURNS 0 OR SOMETHING.
        {
            format(dialog, 512, "%s%d x %s (ID:%d)\n", dialog, amount, GetItemName(item), item);
        }
        ShowPlayerDialog(playerid, DIALOG_ITEMSGUI, DIALOG_STYLE_LIST, "Items", dialog, "Select", "Close"); // CHECK FOR VALID ID.
    }
    else SendClientMessage(playerid, -1, "Bad option");
    return 1;
}
Check that the function GetPlayerItems and the dialogid returns a valid id. And I also recommend you not to put else just before return 1;

You can delete that else or put it at the beginning with a different syntax, for example, if(strcmp(...) != 0 && strcmp(...) != 0) return SOMETHING;
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)