Using a non-constant expression as a constant expression?
#3

I'm attempting to create a custom function upon sendLongMessage,
pawn Код:
stock SendLongMessage( playerid, color, string[], max_chars=80)
{
    new MAX_CHARS_PER_LINE = 80;
    if(max_chars)
    {
        MAX_CHARS_PER_LINE = max_chars;
    }
   
    new length = strlen(string),
        lines = length / MAX_CHARS_PER_LINE;
       
    if(( length % MAX_CHARS_PER_LINE ))
        ++lines;
       
    new line[MAX_CHARS_PER_LINE + 5];
    new _:index;
    while( index < lines )
    {
        if(index == 0)
            strmid(line, string, ( index * MAX_CHARS_PER_LINE ), ( index * MAX_CHARS_PER_LINE ) + MAX_CHARS_PER_LINE);
        else
            strmid(line, string, ( index * MAX_CHARS_PER_LINE ), ( index * MAX_CHARS_PER_LINE ) + MAX_CHARS_PER_LINE);
           
        if(lines > 1)
        {
            if(index == 0)
            {
                format(line, sizeof line, "%s ...", line);
            }
            else if(index > 0 && (index + 1) < lines)
            {
                format(line, sizeof line, "... %s ...", line);
            }
            else
            {
                format(line, sizeof line, "... %s", line);
            }
        }
       
        SendClientMessage( playerid, color, line );
        index++;
    }
    return 1;
}
It would have been nice if it's being able to be edited by a declared number.
Guess I'd need to move into the actual functions that are using it.

Thanks anyway!
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)