Error: unknown command
#1

Hey, when I try to run the commands, I simply get "Error: unknown command" like it doesn't exists, anyone ?
PHP код:
CMD:editarray(playerid)
{
    new 
string[((0x7FFFFFFF) + 2) * 10];
    for(new 
i = 1; i <= sizeof(Array); i++) format(string, sizeof(string), "%sArray[%d] = %d\n", string, i, Array[i]);
    
ShowPlayerDialog(playerid, DIALOG_ARRAY, DIALOG_STYLE_LIST, "Edit the array as you wish:", string, "Edit", "Cancel");
    return 
1;
}
//
CMD:sortarray(playerid)
{
    new 
temp, count;
    for(new 
i = 0; i < sizeof(Array); i++)
    {
        if(Array[
i] > Array[i+1])
        {
            
temp = Array[count];
            Array[
count++] = Array[i];
            Array[
i] = temp;
        }
    }
    return 
1;
}
//
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(
dialogid)
    {
        case 
DIALOG_ARRAY:
        {
            if(
response)
            {
                new 
string[10];
                
format(string, sizeof(string), "Array[%d] edition:", listitem);
                
SetPVarInt(playerid, "cell", listitem);
                
ShowPlayerDialog(playerid, DIALOG_EDIT, DIALOG_STYLE_INPUT, string, "Type in a number.", "Okay", "Cancel");
            }
            else 
SendClientMessage(playerid, -1, "You have decided to abort the array edition.");
        }
        case 
DIALOG_EDIT:
        {
            if(
response)
            {
                new 
string[((0x7FFFFFFF) + 2) * 10];
                Array[
GetPVarInt(playerid, "cell")] = strval(inputtext);
                
SendClientMessage(playerid, -1, "You have edited a number in the array, this is the refreshed one.");
                for(new 
i = 1; i <= sizeof(Array); i++) format(string, sizeof(string), "%s%d\n", string, Array[i]);
                
ShowPlayerDialog(playerid, DIALOG_ARRAY, DIALOG_STYLE_LIST, "Edit the array as you wish:", string, "Edit", "Cancel");
            }
            else
            {
                
DeletePVar(playerid, "cell");
                
SendClientMessage(playerid, -1, "You have aborted the array edition.");
            }
        }
    }
    return 
0;
} 
Reply
#2

Код:
for(new i = 1; i <= sizeof(Array); i++)
This is wrong, the last valid index is always size-1
Reply
#3

Use onplayercommandperformed :P if you use zcmd

Код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
    if(success == 0)
    {
        return SendClientMessage(playerid, YOUR_COLOR, "Unknown command, use /help or /cmds"); // You can change his message.
    }
    return 0;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)