/advertise - max chars
#7

If you want

pawn Код:
/**
 *  Sends a wrapped message to player with indentation
 *  @param  playerid    The playerid to send the message to
 *  @param  colour      The colour of the message
 *  @param  msg         The message to send
 *  @param  maxlength   The length to wrap to
 *  @param  prefix      The string to indent with
 */

stock SendWrappedMessageToPlayer(playerid, colour, const msg[], maxlength=85, const prefix[]="  ")
{
    new length = strlen(msg);
    if(length <= maxlength) {
        SendClientMessage(playerid, colour, msg);
        return;
    }
    new string[MAX_INPUT], idx;
    for(new i, space, plen, bool:useprefix; i < length; i++) {
        if(i - idx + plen >= maxlength) {
            if(idx == space || i - space >= 25) {
                strmid(string, msg, idx, i);
                idx = i;
            } else {
                strmid(string, msg, idx, space);
                idx = space + 1;
            }
            if(useprefix) {
                strins(string, prefix, 0);
            } else {
                plen = strlen(prefix);
                useprefix = true;
            }
            SendClientMessage(playerid, colour, string);
        } else if(msg[i] == ' ') {
            space = i;
        }
    }
    if(idx < length) {
        strmid(string, msg, idx, length);
        strins(string, prefix, 0);
        SendClientMessage(playerid, colour, string);
    }
    return;
}
pawn Код:
/**
 *  Sends a wrapped message to all players with indentation
 *  @param  colour      The colour of the message
 *  @param  msg         The message to send
 *  @param  maxlength   The length to wrap to
 *  @param  prefix      The string to indent with
 */

stock SendWrappedMessageToAll(colour, const msg[], maxlength=85, const prefix[]="  ")
{
    new length = strlen(msg);
    if(length <= maxlength) {
        SendClientMessageToAll(colour, msg);
        return;
    }
    new string[MAX_INPUT], idx;
    for(new i, space, plen, bool:useprefix; i < length; i++) {
        if(i - idx + plen >= maxlength) {
            if(idx == space || i - space >= 25) {
                strmid(string, msg, idx, i);
                idx = i;
            } else {
                strmid(string, msg, idx, space);
                idx = space + 1;
            }
            if(useprefix) {
                strins(string, prefix, 0);
            } else {
                plen = strlen(prefix);
                useprefix = true;
            }
            SendClientMessageToAll(colour, string);
        } else if(msg[i] == ' ') {
            space = i;
        }
    }
    if(idx < length) {
        strmid(string, msg, idx, length);
        strins(string, prefix, 0);
        SendClientMessageToAll(colour, string);
    }
    return;
}
Reply


Messages In This Thread
/advertise - max chars - by [WS]Hyper - 27.10.2009, 17:08
Re: /advertise - max chars - by woot - 27.10.2009, 17:15
Re: /advertise - max chars - by [WS]Hyper - 27.10.2009, 17:57
Re: /advertise - max chars - by MenaceX^ - 27.10.2009, 18:04
Re: /advertise - max chars - by MadeMan - 27.10.2009, 18:08
Re: /advertise - max chars - by [WS]Hyper - 27.10.2009, 18:40
Re: /advertise - max chars - by Dabombber - 28.10.2009, 13:34
Re: /advertise - max chars - by [WS]Hyper - 28.10.2009, 14:49

Forum Jump:


Users browsing this thread: 1 Guest(s)