01.10.2016, 22:50
Hey guys, I'm running a small code that sorts an array from lowest to highest, the problem is that I want to present the sorted array in a message box dialog after the sorting.
But for some reason, I get an "Error: unknown command" after typing the command, and it still sorts the array.
Another thing I noticed - I tried doing the sorting without the dialog, still "unknown command"
Anyone ?
But for some reason, I get an "Error: unknown command" after typing the command, and it still sorts the array.
Another thing I noticed - I tried doing the sorting without the dialog, still "unknown command"
Anyone ?
PHP код:
if(!strcmp(cmdtext, "/sortarray"))
{
new tmp, string[1024];
for(new j = 0; j <= sizeof(Array); j++)
{
for(new i = 0; i < sizeof(Array); i++)
{
if(Array[i] > Array[i+1] && Array[i+1] < sizeof(Array))
{
tmp = Array[i];
Array[i] = Array[i+1];
Array[i+1] = tmp;
}
}
}
for(new i = 0; i < sizeof(Array); i++) format(string, sizeof(string), "%sArray[%d] = %d", string, i, Array[i]);
ShowPlayerDialog(playerid, DIALOG_SORT, DIALOG_STYLE_MSGBOX, "Dialog Sorting", string, "Close", "");
return 1;
}