SA-MP Forums Archive
Error: unknown command - 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: Error: unknown command (/showthread.php?tid=618129)



Error: unknown command - NeXoR - 01.10.2016

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 
1<= sizeof(Array); i++) format(stringsizeof(string), "%sArray[%d] = %d\n"stringi, Array[i]);
    
ShowPlayerDialog(playeridDIALOG_ARRAYDIALOG_STYLE_LIST"Edit the array as you wish:"string"Edit""Cancel");
    return 
1;
}
//
CMD:sortarray(playerid)
{
    new 
tempcount;
    for(new 
0sizeof(Array); i++)
    {
        if(Array[
i] > Array[i+1])
        {
            
temp = Array[count];
            Array[
count++] = Array[i];
            Array[
i] = temp;
        }
    }
    return 
1;
}
//
public OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    switch(
dialogid)
    {
        case 
DIALOG_ARRAY:
        {
            if(
response)
            {
                new 
string[10];
                
format(stringsizeof(string), "Array[%d] edition:"listitem);
                
SetPVarInt(playerid"cell"listitem);
                
ShowPlayerDialog(playeridDIALOG_EDITDIALOG_STYLE_INPUTstring"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 
1<= sizeof(Array); i++) format(stringsizeof(string), "%s%d\n"string, Array[i]);
                
ShowPlayerDialog(playeridDIALOG_ARRAYDIALOG_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;




Re: Error: unknown command - Konstantinos - 01.10.2016

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


Re: Error: unknown command - ActionTanki91 - 01.10.2016

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