PM System error
#1

Error:
Код:
error 008: must be a constant expression; assumed zero
Код:
CMD:pm(playerid, cmdtext[])
{
    new idx = strfind(cmdtext, " ", true);
    if((cmdtext[0] == EOS) || ((cmdtext[0] == '\1') && (cmdtext[1] == EOS)) || (idx == -1)) {
    SendClientMessage(playerid,COLOR_RED,"Usage: /pm [id] [message]");
    return 1;
    }
    if(cmdtext[idx + 1] == EOS) {
    SendClientMessage(playerid,COLOR_RED,"Usage: /pm [id] [message]");
    return 1;
    }
    cmdtext[idx++] = EOS;
    new
    id = strval(cmdtext);
    if(!IsPlayerConnected(id)) {
    SendClientMessage(playerid,COLOR_RED,"Invalid Player ID");
    return 1;
    }
    if(playerid == id) {
    SendClientMessage(playerid,COLOR_RED,"You cannot PM yourself.");
    return 1;
    }
    new
    string[256];
    if(TogPM{id} == 0) return SendClientMessage(playerid, COLOR_ERROR, "This player has turned off his PM's!");
    else
    GetPlayerName(id, string, MAX_PLAYER_NAME);
    format(string, sizeof string, "[PM] sent to %s(%d): {FFFFFF}%s", string, id, cmdtext[idx]);
    SendClientMessage(playerid, COLOR_RED, string);

    GetPlayerName(playerid, string, MAX_PLAYER_NAME);
    format(string, sizeof string, "[PM] from %s(%d): {FFFFFF}%s", string, playerid, cmdtext[idx]);
    SendClientMessage(id, COLOR_RED, string);
    printf("PM: %s", cmdtext[idx]);
    return 1;
}
Reply
#2

Bump
Reply
#3

Which line is the error appearing on?
Reply
#4

What do you mean?
(I'm new at scripting)
Reply
#5

Before:
pawn Код:
error 008: must be a constant expression; assumed zero
shows the number line inside parentheses; for example: (line_number_here).

Goto that line and paste it here.

By the way, wouldn't be easier to just do:
pawn Код:
if(isnull(cmdtext)) return SendClientMessage(playerid,COLOR_RED,"Usage: /pm [id] [message]");
// Assuming cmdtext is similar to "params".
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)