SA-MP Forums Archive
Notes system won't work - 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: Notes system won't work (/showthread.php?tid=307340)



Notes system won't work - Outcast - 30.12.2011

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.

Can you please help me out?

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]");
    }



Re: Notes system won't work - Outcast - 30.12.2011

Bump, anyone please?


Re: Notes system won't work - ғαιιοцт - 30.12.2011

I think the problem is the "10" in your strcmp lines.
Remove that parameter (it's an optional parameter) and try again

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.