Enum loop string
#1

Hello. I'm trying to go through all the string with a loop (for) and then see if is empty and to keep my message. Is it possible to do what I'm doing ?. I pulled the following errors:

Код:
 error 001: expected token: ";", but found "-identifier-"
 error 010: invalid function or declaration
warning 203: symbol is never used: "msj"
warning 203: symbol is never used: "ChatLog"
pawn Код:
CMD:createlog(playerid,[params])
{
    new msj[30];
    if(!sscanf(params, "s[30]",msj))
    {
        for(new i; i < sizeof(ChatLog))
        {
            if(isnull(ChatLog[i]))
            {
                ChatLog[i] = msj;  
            }
            else
            {
                SendClientMessage(playerid, -1, "all slots are filled.");
            }
        }
    }
    else
    {
        SendClientMessage(playerid, -1, "Use /createlog [text]");
    }
    return 1;
}
Reply
#2

A for-loop ALWAYS has three parts separated by semicolons: the initializer, the condition and the increment. Any part can be omitted but the two semicolons must always be there. That's what the error is complaining about.

Some more points of thought: you don't need to use sscanf if you only expect string input. Secondly, you can't possibly know if there aren't any free slots before you have checked them all. If slot 0 happens to be filled the message will be sent even though other slots may be empty.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)