SA-MP Forums Archive
SendClientMessage - 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: SendClientMessage (/showthread.php?tid=599583)



SendClientMessage - Sheperc - 27.01.2016

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.


Re: SendClientMessage - Lucky13 - 27.01.2016

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



Re: SendClientMessage - FreAkeD - 27.01.2016

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

https://sampwiki.blast.hk/wiki/Limits


Re: SendClientMessage - -CaRRoT - 27.01.2016

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