SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 02/05/2015, 03:58 PM   #1
Ahmad45123
Gangsta
 
Ahmad45123's Avatar
 
Join Date: Oct 2013
Location: Egypt
Posts: 827
Reputation: 187
Default How to break up long messages to multiple ones.

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 Code:
#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.
__________________

ExtremeStudio

The Best SAMP IDE.
Ahmad45123 is offline   Reply With Quote
Old 02/05/2015, 04:02 PM   #2
SickAttack
High-roller
 
Join Date: Dec 2013
Posts: 4,768
Reputation: 754
Default Re: How to break up long messages to multiple ones.

http://forum.sa-mp.com/showthread.php?p=3086141
SickAttack is offline   Reply With Quote
Old 02/05/2015, 04:06 PM   #3
Mencent
High-roller
 
Mencent's Avatar
 
Join Date: Mar 2015
Location: Lower Saxony (Niedersachsen)
Posts: 1,311
Reputation: 92
Default Re: How to break up long messages to multiple ones.

Hello!

Maybe this work:
PHP Code:
#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;

__________________
Best wishes,
Mencent

(Sorry for my bad english, I hope you can understand this!)
Mencent is offline   Reply With Quote
Old 02/05/2015, 04:40 PM   #4
Ahmad45123
Gangsta
 
Ahmad45123's Avatar
 
Join Date: Oct 2013
Location: Egypt
Posts: 827
Reputation: 187
Default Re: How to break up long messages to multiple ones.

Quote:
Originally Posted by SickAttack View Post
Thanks alot mate.
__________________

ExtremeStudio

The Best SAMP IDE.
Ahmad45123 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
Long messages [128 char +] ic3cr3am Scripting Help 13 29/09/2013 01:57 PM
[FilterScript] Welcome Messages Basic V2- Under Development (Still adding messages and commands) xF3AR Filterscripts 11 30/03/2013 09:20 AM
Signature after a long break. Mr.Hades Everything and Nothing 7 29/08/2012 09:02 AM
Messages too long ? The__ Scripting Help 4 02/08/2012 11:41 PM
Long messages with ShowPlayerDialog THE_KNOWN Help Archive 4 23/04/2011 04:19 PM


All times are GMT. The time now is 08:52 PM.


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