SendClientMessage
#1

Hi there.

For the past hours I have been having some issues with SendClientMessage. The problem is that the text cuts off after 144 letters or something like that. It's like if I use /say and long text here then SendClientMessage will return only a half text for example. Any way to fix this? Thank you.
Reply
#2

Код:
 
new string[256];
format(string,sizeof(string)," Your long message here");
SendClientMessage(playerid,YOUR_COLOR,string);
Reply
#3

You should also take a look at the server property limits.

https://sampwiki.blast.hk/wiki/Limits
Reply
#4

You gotta split the text as there's a limit to the amount of chars in the client.

Here's a function for it.

Код:
#define EX_SPLITLENGTH 118

stock SendSplitMessage(playerid, color,final[])
{
    new buffer[EX_SPLITLENGTH+10];
    new len = strlen(final);
    if(len>EX_SPLITLENGTH)
    {
        new times = (len/EX_SPLITLENGTH);
        for(new i = 0; i < times+1; i++)
        {
            strdel(buffer, 0, EX_SPLITLENGTH+5);
            if(len-(i*EX_SPLITLENGTH)>EX_SPLITLENGTH)
            {
                strmid(buffer, final, EX_SPLITLENGTH*i, EX_SPLITLENGTH*(i+1));
                if(!i)
                	format(buffer, sizeof(buffer), "%s ...", buffer);
				else
				    format(buffer, sizeof(buffer), "... %s ...", buffer);
            }
            else
            {
                strmid(buffer, final, EX_SPLITLENGTH*i, len);
				format(buffer, sizeof(buffer), "... %s", buffer);
            }
            SendClientMessage(playerid, color, buffer);
        }
    }
    else
    {
        SendClientMessage(playerid, color, final);
    }
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)