SA-MP Forums Archive
Invalid Command Lenght: Exceeding 50 characters - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Invalid Command Lenght: Exceeding 50 characters (/showthread.php?tid=260553)



Invalid Command Lenght: Exceeding 50 characters - Mike Garber - 09.06.2011

I was doing some testing in my gamemode, and this command always worked before.
Now if i type /ooc [somethinglongerthenXchars] it says this in red.

As you can see i'm using ZCMD+sscanf (2.0)

pawn Код:
COMMAND:ooc(playerid,params[])
{
    new string[164];
    if (!sscanf(params,"s[164]",string))
    {
        if(pData[playerid][pMuted] != 1)
        {
            new str[128];
            new log[128];
            new month[12];
            new hh,mm,ss,y,m,d;
            gettime(hh,mm,ss);
            getdate(y,m,d);
            format(month, 12, "%s", Months[m-1]);
            format(str,sizeof(str),"OOC | %s: %s",PlayerName(playerid),string);
            format(log,sizeof(log),"[%s %d, %d, %d:%d:%d] %s: %s\r\n",month,d,y,hh,mm,ss,PlayerName(playerid),string);
            new File:lfile = fopen("TPRP/Logs/OOC-Chat.log",io_append);
            fwrite(lfile,log);
            fclose(lfile);
            SendClientMessageToAll(COLOR_DARKSLATEGRAY,str);
        }
        else return SendClientMessage(playerid,COLOR_RED,"ERROR: You have been muted by Staff.");
    }
    else return SendClientMessage(playerid,-1,"USAGE: /gm [message]");
    return 1;
}



Respuesta: Invalid Command Lenght: Exceeding 50 characters - admantis - 09.06.2011

It can refeer to the callback OnPlayerCommandPerformed.


Re: Invalid Command Lenght: Exceeding 50 characters - Mike Garber - 09.06.2011

There's nothing in there that can cause this. This is from my own script, so i know there's nothing in my script that would cause this error message,
if there isn't anything wrong with my command above, that is.


Re: Invalid Command Lenght: Exceeding 50 characters - Calgon - 09.06.2011

Delete the code that you DON'T need.

pawn Код:
COMMAND:ooc(playerid,params[]) {
    if(isnull(params))
        return SendClientMessage(playerid, -1, "USAGE: /gm [message]");
       
    if(pData[playerid][pMuted] != 1) {
        new str[128];
        new log[128];
        new month[12];
        new hh,mm,ss,y,m,d;
        gettime(hh,mm,ss);
        getdate(y,m,d);
        format(month, 12, "%s", Months[m-1]);
        format(str,sizeof(str),"OOC | %s: %s",PlayerName(playerid),params);
        format(log,sizeof(log),"[%s %d, %d, %d:%d:%d] %s: %s\r\n",month,d,y,hh,mm,ss,PlayerName(playerid),params);
        new File:lfile = fopen("TPRP/Logs/OOC-Chat.log",io_append);
        fwrite(lfile,log);
        fclose(lfile);
        SendClientMessageToAll(COLOR_DARKSLATEGRAY,str);
    }
    else return SendClientMessage(playerid,COLOR_RED,"ERROR: You have been muted by Staff.");
    return 1;
}



Re: Invalid Command Lenght: Exceeding 50 characters - Mike Garber - 09.06.2011

Quote:
Originally Posted by Calg00ne
Посмотреть сообщение
Delete the code that you DON'T need.

pawn Код:
COMMAND:ooc(playerid,params[]) {
    if(isnull(params))
        return SendClientMessage(playerid, -1, "USAGE: /gm [message]");
       
    if(pData[playerid][pMuted] != 1) {
        new str[128];
        new log[128];
        new month[12];
        new hh,mm,ss,y,m,d;
        gettime(hh,mm,ss);
        getdate(y,m,d);
        format(month, 12, "%s", Months[m-1]);
        format(str,sizeof(str),"OOC | %s: %s",PlayerName(playerid),params);
        format(log,sizeof(log),"[%s %d, %d, %d:%d:%d] %s: %s\r\n",month,d,y,hh,mm,ss,PlayerName(playerid),params);
        new File:lfile = fopen("TPRP/Logs/OOC-Chat.log",io_append);
        fwrite(lfile,log);
        fclose(lfile);
        SendClientMessageToAll(COLOR_DARKSLATEGRAY,str);
    }
    else return SendClientMessage(playerid,COLOR_RED,"ERROR: You have been muted by Staff.");
    return 1;
}
It's almost the same amount of code, also i have my own style of coding which i suppose everybody has, and i'd not like to change it unless it's causing any problems.

How did my coding cause this message, and how did your edit fix it?
Thanks.


Re: Invalid Command Lenght: Exceeding 50 characters - Calgon - 09.06.2011

You don't need to use sscanf to split params when you only need 1 parameter. You can use isnull to confirm there's anything typed after the command and params contains the main string, so you can just use params if you want a string, or you can use strval(params) to convert the params string into an integer.


Re: Invalid Command Lenght: Exceeding 50 characters - Mike Garber - 09.06.2011

Quote:
Originally Posted by Calg00ne
Посмотреть сообщение
You don't need to use sscanf to split params when you only need 1 parameter. You can use isnull to confirm there's anything typed after the command and params contains the main string, so you can just use params if you want a string, or you can use strval(params) to convert the params string into an integer.
Oh, i didn't think about that, will start doing it. So me creating another string and using it instead of params caused this issue?
I can see how i can save memory by not creating new strings and also how it increases the performance on the command.