Why is this happening ?
#1

So yesterday i asked for an /admin [question] command and a /reply [id] [response] command.
/Reply is working fine but the /admin command is giving me errors

CODE:
pawn Код:
CMD:admin(playerid, params[])
{
    new string[128];
    new sName[MAX_PLAYER_NAME];
    if(sscanf(params, "s", string)) return SendClientMessage(playerid, -1, "Usage /admin [question]");
    GetPlayerName(playerid, sName, sizeof(sName));
    new Message[128];
    format(Message, sizeof(Message), "QUESTION from %s: %s", sName, string);
    for(new i; i < MAX_PLAYERS; i++){
        if(PlayerINFO[i][AdminLevel] >= 1 {
            SendClientMessage(i, -1, Message);
        }
    }
    return 1;
}
ERROR:
Код:
(855) : error 029: invalid expression, assumed zero
855 line is : if(PlayerINFO[i][AdminLevel] >=1 {
Reply
#2

this line
Код:
if(PlayerINFO[i][AdminLevel] >= 1) {
Reply
#3

You forgot to close the if statement. It should be:
pawn Код:
if(PlayerINFO[i][AdminLevel] >=1) {
Also using "s" specifier without a length will give a warning to the console. But since it's not necessary to use sscanf when there is only 1 parameter and that's string, you can just do:
pawn Код:
CMD:admin(playerid, params[])
{
    if(isnull(params)) return SendClientMessage(playerid, -1, "Usage /admin [question]");
    new Message[144], sName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, sName, sizeof(sName));
    format(Message, sizeof(Message), "QUESTION from %s: %s", sName, params);
    for(new i; i < MAX_PLAYERS; i++){
        if(PlayerINFO[i][AdminLevel] >= 1) {
            SendClientMessage(i, -1, Message);
        }
    }
    return 1;
}
Reply
#4

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
You forgot to close the if statement. It should be:
pawn Код:
if(PlayerINFO[i][AdminLevel] >=1) {
Also using "s" specifier without a length will give a warning to the console. But since it's not necessary to use sscanf when there is only 1 parameter and that's string, you can just do:
pawn Код:
CMD:admin(playerid, params[])
{
    if(isnull(params)) return SendClientMessage(playerid, -1, "Usage /admin [question]");
    new Message[144], sName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, sName, sizeof(sName));
    format(Message, sizeof(Message), "QUESTION from %s: %s", sName, params);
    for(new i; i < MAX_PLAYERS; i++){
        if(PlayerINFO[i][AdminLevel] >= 1) {
            SendClientMessage(i, -1, Message);
        }
    }
    return 1;
}
Thanks , rep+ . Are you greek ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)