SA-MP Forums Archive
How to break up long messages to multiple ones. - 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: How to break up long messages to multiple ones. (/showthread.php?tid=572870)



How to break up long messages to multiple ones. - Ahmad45123 - 02.05.2015

I want to create a way so if I sent a message bigger then 125 chars, it gets break to multiple messages so it doesn't get removed by client.

Here is what I did but it doesn't work as intended:
PHP код:
#define MAX_SEND_STR 125
public SendClientMessageEx(playeridcolormsg[])
{
    if(
strlen(msg) > MAX_SEND_STR)
    {
        new 
pendingtxt[300]; format(pendingtxtsizeof(pendingtxt), "%s"msg);
        for(;;)
        {
            if(
strlen(pendingtxt) > MAX_SEND_STR)
            {
                new 
txtsent[101];
                
strmid(txtsentpendingtxt0MAX_SEND_STR); strdel(pendingtxt0MAX_SEND_STR);
                
SendClientMessage(playeridcolortxtsent);
            } else {
                return 
SendClientMessage(playeridcolorpendingtxt); //this should break the loop.
            
}
        }
    } else {
         return 
SendClientMessage(playeridcolormsg);
    }
    return 
0;

Help greatly appreciated.


Re: How to break up long messages to multiple ones. - SickAttack - 02.05.2015

https://sampforum.blast.hk/showthread.php?pid=3086141#pid3086141


Re: How to break up long messages to multiple ones. - Mencent - 02.05.2015

Hello!

Maybe this work:
PHP код:
#define MAX_SEND_STR 125
public SendClientMessageEx(playerid,color,msg[])
{
    if(
strlen(msg) > MAX_SEND_STR)
    {
        new 
_length strlen(msg),pendingtxt[300],txtsent[MAX_SEND_STR];
        
format(pendingtxt,sizeof pendingtxt,msg);
        
strmid(txtsent,pendingtxt,0,MAX_SEND_STR);
        
strdel(pendingtxt,0,MAX_SEND_STR);
        
SendClientMessage(playerid,color,txtsent);
        
SendClientMessage(playerid,color,pendingtxt);
        return 
1;
    }
    else 
SendClientMessage(playerid,color,msg);
    return 
0;




Re: How to break up long messages to multiple ones. - Ahmad45123 - 02.05.2015

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
Thanks alot mate.