SA-MP Forums Archive
Command will execute, but returns INVALID 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: Command will execute, but returns INVALID COMMAND! (/showthread.php?tid=358907)



Command will execute, but returns INVALID COMMAND! - [MM]18240[FMB] - 12.07.2012

This is the code
pawn Код:
if(!strcmp(cmdtext, "/hitlist", true))
    {
        new count = 0;
        SendClientMessage(playerid, COLOR_MSG, "Listing currently placed hits:");
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i) && hit[i] > 0)
            {
                new string[256];
                format(string, 256, "Hit on %s (%i) for $%i", ReturnPlayerName(i), i, hit[i]);
                SendClientMessage(playerid, COLOR_FOUND, string);
                count++;
            }
        }
        if(count == 0)
        {
            SendClientMessage(playerid, COLOR_ERROR, "No hits placed at this time!");
        }
    }
I can do /hitlist and see who has a hit on them, but it still says SERVER: INVALID COMMAND TYPE /CMDS FOR COMMANDS!


Re: Command will execute, but returns INVALID COMMAND! - clarencecuzz - 12.07.2012

pawn Код:
if(!strcmp(cmdtext, "/hitlist", true))
    {
        new count = 0;
        SendClientMessage(playerid, COLOR_MSG, "Listing currently placed hits:");
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i) && hit[i] > 0)
            {
                new string[256];
                format(string, 256, "Hit on %s (%i) for $%i", ReturnPlayerName(i), i, hit[i]);
                SendClientMessage(playerid, COLOR_FOUND, string);
                count++;
            }
        }
        if(count == 0)
        {
            SendClientMessage(playerid, COLOR_ERROR, "No hits placed at this time!");
        }
        return 1;
    }



Re: Command will execute, but returns INVALID COMMAND! - [MM]18240[FMB] - 12.07.2012

Repped, I also need help with this
pawn Код:
if(strcmp(cmd, "/help", true) == 0)
    {
        tmp = strtok(cmdtext, idx);
        if(strlen(tmp) == 0) return SendClientMessage(playerid, ERROR, "Use: /help [MESSAGE]");
        new string[250];
        format(string, sizeof(string), "[ ! ] %s [ID:%d] asks : %s", name, playerid, strlen(tmp));
        SendClientMessageToAdmins(string);
        return 1;
    }
It will come up as "18240 asks: ELP E LE!" for the command /help HELP ME PLEASE!


Re: Command will execute, but returns INVALID COMMAND! - Larceny - 12.07.2012

pawn Код:
if(strcmp(cmd, "/help", true) == 0)
{
    tmp = strtok(cmdtext, idx);
    if(strlen(tmp) == 0) return SendClientMessage(playerid, ERROR, "Use: /help [MESSAGE]");
    new string[144];// You don't need 250 cells, because max length displayable is 144
    format(string, sizeof(string), "[ ! ] %s [ID:%d] asks : %s", name, playerid, tmp);/* < strlen returns the length of the string*/
    SendClientMessageToAdmins(string);
    return 1;
}



Re: Command will execute, but returns INVALID COMMAND! - warcodes_ - 12.07.2012

Quote:
Originally Posted by RuiGy
Посмотреть сообщение
pawn Код:
if(strcmp(cmd, "/help", true) == 0)
{
    tmp = strtok(cmdtext, idx);
    if(strlen(tmp) == 0) return SendClientMessage(playerid, ERROR, "Use: /help [MESSAGE]");
    new string[144];// You don't need 250 cells, because max length displayable is 144
    format(string, sizeof(string), "[ ! ] %s [ID:%d] asks : %s", name, playerid, tmp);/* < strlen returns the length of the string*/
    SendClientMessageToAdmins(string);
    return 1;
}
I am pretty sure its 128 cells not 144...


Re: Command will execute, but returns INVALID COMMAND! - Larceny - 12.07.2012

Wiki says 144.


Re: Command will execute, but returns INVALID COMMAND! - warcodes_ - 12.07.2012

Quote:
Originally Posted by RuiGy
Посмотреть сообщение
Wiki says 144.
Hmm thank you for this information.


Re: Command will execute, but returns INVALID COMMAND! - [MM]18240[FMB] - 13.07.2012

Tried it, but now it only shows the first word, like "/help How do I start engine?" will say, "[!] 18240 asks: How"


Re: Command will execute, but returns INVALID COMMAND! - Roko_foko - 13.07.2012

pawn Код:
if(strcmp(cmdtext, "/help", true) == 0)
{
    tmp = strtok(cmdtext, idx);
    if(strlen(tmp) == 0) return SendClientMessage(playerid, ERROR, "Use: /help [MESSAGE]");
    new string[144];
    new pName[MAX_PLAYER_NAME];
    GetPlayerName(pName,sizeof(pName),playerid);//<---------------add this
    format(string, sizeof(string), "[ ! ] %s [ID:%d] asks : %s", pName, playerid, cmdtext[6]);//put cmdtext[6], not tmp
    SendClientMessageToAdmins(string);
    return 1;
}



Re: Command will execute, but returns INVALID COMMAND! - Larceny - 13.07.2012

pawn Код:
if(!strcmp(cmdtext, "/help", true, 5))
{
    if(!cmdtext[5]) return SendClientMessage(playerid, ERROR, "Use: /help [MESSAGE]");
    new strText[144], playerName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, playerName, MAX_PLAYER_NAME);
    format(strText, sizeof(strText), "[ ! ] %s [ID:%d] asks : %s", playerName, playerid, cmdtext[5]);
    SendClientMessageToAdmins(strText);
    return 1;
}