How to break up long messages to multiple ones.
#1

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.
Reply
#2

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

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;

Reply
#4

Thanks alot mate.
Reply


Forum Jump:


Users browsing this thread: