Send Long Message
#1

I saw a function a while ago to send a long message to a player, the format would be like this:
pawn Код:
SendLongMessage(playerid, COLOR_RED, "This is a very very long message and it's going to overflow hopefully yada yada yada");
And the output would be something like:
This is a very very long message and it's going to ...
...overflow hopefully yada yada yada


Basically if the message was longer than 128 bytes, it would split it.
Can someone give me it?
Reply
#2

Hi there,

You can get an idea from this https://sampforum.blast.hk/showthread.php?tid=220209
Reply
#3

Davz* I need a way to do it automatically, because I'm sending a message that the player has sent
Reply
#4

pawn Код:
SendLongMessage(playerid, COLOR_RED, "This is a very very long message and..\n..it's going to overflow hopefully yada yada yada");
Try this.
Reply
#5

You can't use \n in Client Message.
Reply
#6

https://sampwiki.blast.hk/wiki/Strlen use this to get string length
if sting is like 200 u can create 2 other string variables and give them ur message then use this: https://sampwiki.blast.hk/wiki/Strdel and delete 1st string for example from 128 other to 129. If u need '...' use https://sampwiki.blast.hk/wiki/Strins
Reply
#7

Darnell read before you reply.

Thanks marrcko, I was hoping someone could just give me it, but thanks anyway.
Reply
#8

no problem.. probably i could script it but i'm too lazy now
Reply
#9

I guess you're searching for this: (had it for long.. )

pawn Код:
//On top of your script:
#define MAX_CHARS_PER_LINE 80
#define FINAL_DOTS

//somewhere outside functions:
stock sendLongMessage( playerid , color , 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, color, _Line );
        ///////////
        _i@Index++;
    }
    return 1;
}
//Credits to Miki
Reply
#10

Thanks for the credits D:
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)