Message splitter
#1

Hi,

Who can give good message splitter? like if you write a lot of text, in commands, /say and something, need to send message in new line
Reply
#2

You can simple do one by using sscanf like below.

PHP код:
SendMessageZ(const playerid, const colormessage[])
{
    new 
len strlen(message);
    if(
len 128)
    {
        new 
message1[150], color2;
        
GetMessageColor(messagecolor2len);
        
sscanf(message,"s[128]",message1);
        
SendClientMessage(playeridcolormessage1);
        
sscanf(message[127],"s[128]",message1);
        if(
color2 != -999999)
        {
            
format(message1sizeof message1,"{%d}%s",color2,message1);
            return 
SendClientMessage(playeridcolormessage1);
        }
        else
        {
            return 
SendClientMessage(playeridcolormessage1);
        }
    }
    else
    {
        return 
SendClientMessage(playeridcolormessage);
    }
}
GetMessageColor(const message[], &color2len)
{
    new 
strcolor[9];
    for(new 
= (len-1); > -1i--)
    {
        if(
&& message[i] == '}' && message[i-7] == '{')
        {
            
strmid(strcolormessagei-6i);
            
color2 strval(strcolor);
            break;
        }
    }
    return 
1;

Reply
#3

When can by?
if(color2 != -999999)
{
Reply
#4

Quote:
Originally Posted by MerryDeer
Посмотреть сообщение
When can by?
if(color2 != -999999)
{
when there's a custom color used in the message words.

you can learn more about it here
https://sampwiki.blast.hk/wiki/Colors_L...olor_embedding

and here
https://sampforum.blast.hk/showthread.php?tid=250389
Reply
#5

What is bad with this function:

Код:
stock SMessage(playerid,color,str[],len=128,lines=20){
	if(!len||!str[0])return true;
	new c=0,x=0;if(len>128||len<0)len=128;
	for(new i=0,j,y=0;i<lines;y=0,i++){
		for(j=x+_:!i;j<x+len&&str[j];j++){
			if(str[j]<33){if(str[j-1]>32)y=j;}
		}if(!str[j])j=-1;else{
			if(!y){
				if(str[j]>32||str[j-1]<33)c=str[j];else c=0;y=j;
			}else c=0;str[y]=0;
		}if(playerid<0)SendClientMessageToAll(color,str[x]);
		else SendClientMessage(playerid,color,str[x]);
		if(j<0)break;str[y]=c;x=y+(c?0:1);
	}return true;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)