Whenever I type /note, instead of getting an Usage: /note [add/view...] message, I get /note add [1-5]. And if I type /note view or /note show, it says Unknown Command.
pawn Код:
if (strcmp("/note", cmdtext, true, 100) == 0)
{
if(!IsPlayerConnected(playerid)) return 1;
new cmd[30], params[120];
sscanf(cmdtext, "ss", cmd, params);
if(strcmp("add", params, true, 10) == 0){
new tparams[10], option, text[100];
sscanf(params, "sis", tparams, option, text);
if(option == 1){
if(strlen(pInfo[playerid][pNote1]) != 0) return SendClientMessage(playerid, COLOR_RED, "[ERROR] That note spot is taken.");
pInfo[playerid][pNote1] = text;
return 1;
}
if(option == 2){
if(strlen(pInfo[playerid][pNote2]) != 0) return SendClientMessage(playerid, COLOR_RED, "[ERROR] That note spot is taken.");
pInfo[playerid][pNote2] = text;
return 1;
}
if(option == 3){
if(strlen(pInfo[playerid][pNote3]) != 0) return SendClientMessage(playerid, COLOR_RED, "[ERROR] That note spot is taken.");
pInfo[playerid][pNote3] = text;
return 1;
}
if(option == 4){
if(strlen(pInfo[playerid][pNote4]) != 0) return SendClientMessage(playerid, COLOR_RED, "[ERROR] That note spot is taken.");
pInfo[playerid][pNote4] = text;
return 1;
}
if(option == 5){
if(strlen(pInfo[playerid][pNote5]) != 0) return SendClientMessage(playerid, COLOR_RED, "[ERROR] That note spot is taken.");
pInfo[playerid][pNote5] = text;
return 1;
}
return SendClientMessage(playerid, COLOR_USAGE, "[USAGE] /note add [1-5]");
}
if(strcmp("view", params, true, 10) == 0){
new tparams[10], option;
sscanf(params, "si", tparams, option);
if(option == 1){
if(strlen(pInfo[playerid][pNote1]) == 0) return SendClientMessage(playerid, COLOR_RED, "[ERROR] That note slot is empty.");
new notetext[120];
format(notetext, sizeof(notetext), "Note 1: %s", pInfo[playerid][pNote1]);
return SendClientMessage(playerid, COLOR_NOTE, notetext);
}
if(option == 2){
if(strlen(pInfo[playerid][pNote2]) == 0) return SendClientMessage(playerid, COLOR_RED, "[ERROR] That note slot is empty.");
new notetext[120];
format(notetext, sizeof(notetext), "Note 2: %s", pInfo[playerid][pNote2]);
return SendClientMessage(playerid, COLOR_NOTE, notetext);
}
if(option == 3){
if(strlen(pInfo[playerid][pNote3]) == 0) return SendClientMessage(playerid, COLOR_RED, "[ERROR] That note slot is empty.");
new notetext[120];
format(notetext, sizeof(notetext), "Note 3: %s", pInfo[playerid][pNote3]);
return SendClientMessage(playerid, COLOR_NOTE, notetext);
}
if(option == 4){
if(strlen(pInfo[playerid][pNote4]) == 0) return SendClientMessage(playerid, COLOR_RED, "[ERROR] That note slot is empty.");
new notetext[120];
format(notetext, sizeof(notetext), "Note 4: %s", pInfo[playerid][pNote4]);
return SendClientMessage(playerid, COLOR_NOTE, notetext);
}
if(option == 5){
if(strlen(pInfo[playerid][pNote5]) == 0) return SendClientMessage(playerid, COLOR_RED, "[ERROR] That note slot is empty.");
new notetext[120];
format(notetext, sizeof(notetext), "Note 5: %s", pInfo[playerid][pNote5]);
return SendClientMessage(playerid, COLOR_NOTE, notetext);
}
return SendClientMessage(playerid, COLOR_USAGE, "[USAGE] /note view [1-5]");
}
if(strcmp("show", params, true, 10) == 0){
new tparams[10], option, id;
sscanf(params, "sid", tparams, option, id);
if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, "[ERROR] Invalid ID");
if(option == 1){
if(strlen(pInfo[playerid][pNote1]) == 0) return SendClientMessage(playerid, COLOR_RED, "[ERROR] That note slot is empty.");
new notetext[120];
format(notetext, sizeof(notetext), "Note 1: %s", pInfo[playerid][pNote1]);
return SendClientMessage(id, COLOR_NOTE, notetext);
}
if(option == 2){
if(strlen(pInfo[playerid][pNote2]) == 0) return SendClientMessage(playerid, COLOR_RED, "[ERROR] That note slot is empty.");
new notetext[120];
format(notetext, sizeof(notetext), "Note 2: %s", pInfo[playerid][pNote2]);
return SendClientMessage(id, COLOR_NOTE, notetext);
}
if(option == 3){
if(strlen(pInfo[playerid][pNote3]) == 0) return SendClientMessage(playerid, COLOR_RED, "[ERROR] That note slot is empty.");
new notetext[120];
format(notetext, sizeof(notetext), "Note 3: %s", pInfo[playerid][pNote3]);
return SendClientMessage(id, COLOR_NOTE, notetext);
}
if(option == 4){
if(strlen(pInfo[playerid][pNote4]) == 0) return SendClientMessage(playerid, COLOR_RED, "[ERROR] That note slot is empty.");
new notetext[120];
format(notetext, sizeof(notetext), "Note 4: %s", pInfo[playerid][pNote4]);
return SendClientMessage(id, COLOR_NOTE, notetext);
}
if(option == 5){
if(strlen(pInfo[playerid][pNote5]) == 0) return SendClientMessage(playerid, COLOR_RED, "[ERROR] That note slot is empty.");
new notetext[120];
format(notetext, sizeof(notetext), "Note 5: %s", pInfo[playerid][pNote5]);
return SendClientMessage(id, COLOR_NOTE, notetext);
}
return SendClientMessage(playerid, COLOR_USAGE, "[USAGE] /note show [ID/PartOfName]");
}
return SendClientMessage(playerid, COLOR_USAGE, "[USAGE] /note [add/view/show/delete]");
}
I think the problem is the "10" in your strcmp lines.
The 10 means it will compare the first 10 characters, but there are less than 10 characters. Maybe that's why it also returns 0.