SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 27/01/2016, 07:19 PM   #1
Sheperc
Little Clucker
 
Sheperc's Avatar
 
Join Date: Aug 2015
Location: Lithuania
Posts: 43
Reputation: 3
Default SendClientMessage

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.
Sheperc is offline   Reply With Quote
Old 27/01/2016, 07:20 PM   #2
Lucky13
Huge Clucker
 
Lucky13's Avatar
 
Join Date: Dec 2015
Location: Romania
Posts: 276
Reputation: 70
Default Re: SendClientMessage

Code:
 
new string[256];
format(string,sizeof(string)," Your long message here");
SendClientMessage(playerid,YOUR_COLOR,string);
Lucky13 is offline   Reply With Quote
Old 27/01/2016, 07:24 PM   #3
FreAkeD
Gangsta
 
FreAkeD's Avatar
 
Join Date: May 2012
Location: Australia
Posts: 630
Reputation: 87
Default Re: SendClientMessage

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

http://wiki.sa-mp.com/wiki/Limits
FreAkeD is offline   Reply With Quote
Old 27/01/2016, 07:49 PM   #4
-CaRRoT
High-roller
 
-CaRRoT's Avatar
 
Join Date: Jul 2011
Location: CA, Los Angeles.
Posts: 1,275
Reputation: 344
Default Re: SendClientMessage

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

Here's a function for it.

Code:
#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);
    }
}
-CaRRoT is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SendClientMessage help lramos15 Scripting Help 23 12/11/2013 01:32 AM
Help with SendClientMessage arjanforgames Scripting Help 4 09/07/2013 05:29 PM
SendClientMessage whando Scripting Help 2 20/05/2013 03:39 PM
SendClientMessage only once Tachibana Help Archive 5 24/06/2011 06:06 PM
How to: add value into SendClientMessage? sheepondrugs Help Archive 6 04/09/2010 01:01 PM


All times are GMT. The time now is 10:15 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.