help !
#1

i want to make this thing for examp if i private message someone on my server and the message is to long it should do
pawn Код:
John PM'ed you: Bro where areeeeeeeeeeeeeeeeeeeee yo ...
uuuuuuuuuuuuuuu
like that
Reply
#2

bump!
Reply
#3

-.- can you explain More?
Reply
#4

what is there to explain..? if the text he typed is too large it sends it like this
pawn Код:
Bro where areeeeeeeeeeeeeeeeeeeee yo ... //This is what i mean those dots, i've seen it in a server
uuuuuuuuuuuuuuu
Reply
#5

Use strlen to check if the length is more then what you want.. And if it is extract the more text using strmid and sendClientMessage it again
Reply
#6

i didnt understand please show me an example
Reply
#7

pawn Код:
// This callback gets called whenever a player uses the chat-box
public OnPlayerText(playerid, text[])
{
    // Setup local variables
    new Msg[128], Name[24], SplitText[128];

    // Get the player's name
    GetPlayerName(playerid, Name, sizeof (Name));

    // Check if the entered text is shorter than 70 characters
    if (strlen(text) < 70)
    {
        // Send the message using different colors
        format(Msg, 128, "%s: %s", Name, text);
        SendClientMessageToAll(0xFFFFFFFF, Msg);
    }
    else // The entered text is longer, so split it up in 2 parts
    {
        // Split the text in 2 parts (this is part one)
        strmid(SplitText, text, 0, 69);
        format(Msg, 128, "%s: %s...", Name, SplitText);
        SendClientMessageToAll(0xFFFFFFFF, Msg);

        // Split the text in 2 parts (this is part two)
        strmid(SplitText, text, 69, 127);
        format(Msg, 128, "%s: %s", Name, SplitText);
        SendClientMessageToAll(0xFFFFFFFF, Msg);
    }

    // Don't allow the callback to send the text normally
    return 0;
}
Taken directly from my admin-script (un-related code taken out), it uses a similar system and it works.
Reply
#8

use this

pawn Код:
//use it like
SendLongMessage(playerid, 0xFF8C00FF ,string);//send the long message

//the stock function (please note: i did NOT write this function myself!)
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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)