[Pedido] Quebra de linha automatico
#1

Estou pesquisando e pesquisando e nunca encontro pelo menos uma base, tipo, estou a procura de um sistema que, quando a pessoa digita(tambйm em comandos) pula uma linha caso a mensagem for muito grande.
Reply
#2

PHP код:
#include <a_samp>
public OnPlayerText(playerid, text[])
{
    new 
Texto[144];
    
format(Texto, sizeof(Texto), "%s(%d): %s", Name(playerid), playerid, Texto);
    
    if(
strlen(Texto) < 72) // 1/2
    
{
        
SendClientMessageToAll(-1, Texto);
    }
    else if(
strlen(Texto) > 72) // +1/2
    
{
        new 
Linha[2][73];
        
strmid(Linha[0], Texto, 0, 72, 72);
        
SendClientMessageToAll(-1, Linha[0]);
        
strmid(Linha[1], Texto, 73, 144, 72);
        
SendClientMessageToAll(-1, Linha[1]);
        
strdel(Texto, 0, 144);
        return 
false;
    }
    return 
true;
}
stock Name(playerid)
{
    new 
Name[24];
    
GetPlayerName(playerid, Name, 24);
    return 
Name;
} 
Reply
#3

Funзхes:
PHP код:
#define MAXIMUM_SIZE_LINE 144 // respeitando os limites do SA-MP (144 caracteres em SendClientMessage() )
SendMessage(playerid, color, message[] ) {
    for (;;) {
        if ( 
strlen(message) >= MAXIMUM_SIZE_LINE ) {
            new 
str[MAXIMUM_SIZE_LINE + 1];
            
format(str, sizeof(str), message);
            
strdel(message, 0, MAXIMUM_SIZE_LINE);
            
SendClientMessage(playerid, color, str);
            if ( 
strlen(message) <= MAXIMUM_SIZE_LINE ) {
                
SendClientMessage(playerid, color, message);
                break;
            }
        }
        else {
            
SendClientMessage(playerid, color, message);
            break;
        }
    }
}
SendMessageToAll(color, message[] ) {
    for (;;) {
        if ( 
strlen(message) >= MAXIMUM_SIZE_LINE ) {
            new 
str[MAXIMUM_SIZE_LINE + 1];
            
format(str, sizeof(str), message);
            
strdel(message, 0, MAXIMUM_SIZE_LINE);
            
SendClientMessageToAll(color, str);
            if ( 
strlen(message) <= MAXIMUM_SIZE_LINE ) {
                
SendClientMessageToAll(color, message);
                break;
            }
        }
        else {
            
SendClientMessageToAll(color, message);
            break;
        }
    }
} 
Exemplo idiota de uso:
PHP код:
CMD:mensagem(playerid, params[]) {
    if ( 
isnull(params) )
        
SendClientMessage(playerid, -1, "Use /mensagem [texto]");
    
SendMessage(playerid, -1, params);
    return 
1;
} 
Exemplo menos idiota de uso:
PHP код:
public OnPlayerText(playerid, text[]) {
    
SendMessageToAll(-1, text);
    return 
0;
} 
Quote:
Originally Posted by Nenzittow
Посмотреть сообщение
PHP код:
#include <a_samp>
public OnPlayerText(playerid, text[])
{
    new 
Texto[144];
    
format(Texto, sizeof(Texto), "%s(%d): %s", Name(playerid), playerid, Texto);
    
    if(
strlen(Texto) < 72) // 1/2
    
{
        
SendClientMessageToAll(-1, Texto);
    }
    else if(
strlen(Texto) > 72) // +1/2
    
{
        new 
Linha[2][73];
        
strmid(Linha[0], Texto, 0, 72, 72);
        
SendClientMessageToAll(-1, Linha[0]);
        
strmid(Linha[1], Texto, 73, 144, 72);
        
SendClientMessageToAll(-1, Linha[1]);
        
strdel(Texto, 0, 144);
        return 
false;
    }
    return 
true;
}
stock Name(playerid)
{
    new 
Name[24];
    
GetPlayerName(playerid, Name, 24);
    return 
Name;
} 
Se o texto tiver mais que 144 caracteres nгo vai mostrar a mensagem completa ...
Reply


Forum Jump:


Users browsing this thread: