SA-MP Forums Archive
help ! - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: help ! (/showthread.php?tid=482210)



help ! - yuvraj201 - 20.12.2013

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


Re: help ! - yuvraj201 - 20.12.2013

bump!


Re: help ! - Kells - 20.12.2013

-.- can you explain More?


Re: help ! - yuvraj201 - 20.12.2013

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



Re: help ! - xVIP3Rx - 20.12.2013

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


Re: help ! - yuvraj201 - 20.12.2013

i didnt understand please show me an example


Re: help ! - PowerPC603 - 20.12.2013

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.


Re: help ! - BlackWolf120 - 20.12.2013

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;
}