Command will execute, but returns INVALID COMMAND!
#1

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!
Reply
#2

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;
    }
Reply
#3

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!
Reply
#4

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;
}
Reply
#5

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...
Reply
#6

Wiki says 144.
Reply
#7

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

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

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;
}
Reply
#10

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;
}
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)