Client Message Appear Truncated
#1

So, this is my code:
pawn Код:
CMD:b(playerid, params[])
{
    if (PlayerData[playerid][LoggedIn] == 1 && PlayerData[playerid][Tutorial] == 20)
    {
        new SayString[128]; if (sscanf(params,"s",SayString)) return SendClientMessage(playerid, 0xFF0000AA,"USAGE: /b [Testo]");
        new PlayerName[256]; GetPlayerName(playerid,PlayerName,MAX_PLAYER_NAME);
        PlayerName = str_replace("_"," ",PlayerName);
        if (PlayerData[playerid][Sex] == 0) format(SayString,sizeof(SayString),"{00FFFF}(( {0080FF}%s{00FFFF}: %s ))",PlayerName,SayString);
        else if (PlayerData[playerid][Sex] == 1) format(SayString,sizeof(SayString),"{00FFFF}(( {FF00FF}%s{00FFFF}: %s ))",PlayerName,SayString);
        SendClientMessageToAll(0xFFFFFFFF,SayString);
    }
    return 1;
}
So, if I type /b hello everyone, I hope my roleplay will be nice to you!, the output will be (( Stupid_Boy: hello everyone, I hope my roleplay wil ))
WHY?
Reply
#2

Increase the 'SayString' array. (put it for example 256 characters)
Reply
#3

Quote:
Originally Posted by zxc1
Посмотреть сообщение
Increase the 'SayString' array. (put it for example 256 characters)
No, that wouldn't change anything since the max output in SCM is 128 per line.
Reply
#4

Use this instead of SendClientMessage and increase your array size.

pawn Код:
#define MAX_CHARS_PER_LINE (80)
// Max characters per line.
#define FINAL_DOTS
// Remove it if you don't want dots for new lines.

stock BigMessage(playerid, colr, message[])
{
    new len = strlen(message),
        _iL = len / MAX_CHARS_PER_LINE;

    if( ( len % MAX_CHARS_PER_LINE ) ) _iL++;
    new _Line[MAX_CHARS_PER_LINE + 5];

    new _:_i@Index;
    while( _i@Index < _iL )
    {
        if( _i@Index == 0 )
            strmid( _Line, message, ( _i@Index * MAX_CHARS_PER_LINE ), ( _i@Index * MAX_CHARS_PER_LINE ) + MAX_CHARS_PER_LINE );
        else
            strmid( _Line, message, ( _i@Index * MAX_CHARS_PER_LINE ), ( _i@Index * MAX_CHARS_PER_LINE ) + MAX_CHARS_PER_LINE );

        #if defined FINAL_DOTS
        if( _iL > 1 )
        {
            if( _i@Index == 0 )
            {
                format( _Line, sizeof _Line, "%s ...", _Line );
            }
            else if( _i@Index > 0 && ( _i@Index + 1 ) < _iL )
            {
                format( _Line, sizeof _Line, "... %s ...", _Line );
            }
            else
            {
                format( _Line, sizeof _Line, "... %s", _Line );
            }
        }
        #endif
        ////////////
        SendClientMessage(playerid, colr, _Line );
        ///////////
        _i@Index++;
    }
}
Reply
#5

Try this;
Код:
CMD:b(playerid, params[])
{
    if (PlayerData[playerid][LoggedIn] == 1 && PlayerData[playerid][Tutorial] == 20)
    {
        new SayString[128]; if (sscanf(params,"s[128]",SayString)) return SendClientMessage(playerid, 0xFF0000AA,"USAGE: /b [Testo]");
        new PlayerName[MAX_PLAYER_NAME]; GetPlayerName(playerid,PlayerName,MAX_PLAYER_NAME);
        PlayerName = str_replace("_"," ",PlayerName);
        if (PlayerData[playerid][Sex] == 0) format(SayString,sizeof(SayString),"{00FFFF}(( {0080FF}%s{00FFFF}: %s ))",PlayerName,SayString);
        else if (PlayerData[playerid][Sex] == 1) format(SayString,sizeof(SayString),"{00FFFF}(( {FF00FF}%s{00FFFF}: %s ))",PlayerName,SayString);
        SendClientMessageToAll(0xFFFFFFFF,SayString);
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)