[FilterScript] Перенос чата на строку
#1

Может кому-то понадобится: перенос слов на вторую строку (довольно неплохой вариант)

PHP Code:
в onplayertext закидываем следующее (желательно вниз)
new 
player[MAX_PLAYERS], string[128];
GetPlayerName(playerid, player, sizeof(player));
if(
strlen(text) >= 80)
{
   
SetPlayerChatBubble(playerid,text,0xFFFFFF,150,10000);
   new 
mess[128];
   
strmid(string,text,64,128,128);
   
strdel(text,64,128);
   
format(text, 104, "%s(%d): {FFFFFF}%s",player, playerid, text);
   
format(mess, 88, "%s(%d): {FFFFFF}%s", player, playerid, string);
   for(new 
i = 0; i < MAX_PLAYERS; i++)
     {
       
SendClientMessage(i, GetPlayerColor(playerid), text);
       
SendClientMessage(i, GetPlayerColor(playerid), mess);
     }
return 
false;
}
else
{
SetPlayerChatBubble(playerid,text,0xFFFFFF,150,10000);
format(text, 104, "%s(%d): {FFFFFF}%s", player, playerid, text);
for(new 
i = 0; i < MAX_PLAYERS; i++)
    {
      
SendClientMessage(i, GetPlayerColor(playerid), text);
    }
return 
false;
} 
Reply
#2

Гуано.

pawn Code:
#include <a_samp>
#define PERENOS_S_NICKOM //Закоментировать чтобы во второй строке не указывался никнейм

#if defined PERENOS_S_NICKOM
    #define MESSAGE_LENGTH 80
    #define MESSAGE_LENGTH_START 60
#else
    #define MESSAGE_LENGTH 64
    #define MESSAGE_LENGTH_START 50
#endif

new NameF[MAX_PLAYERS][MAX_PLAYER_NAME];

public OnFilterScriptInit()
{
    for(new playerid = MAX_PLAYERS; playerid--;)
    if(IsPlayerConnected(playerid))
    {
        GetPlayerName(playerid, NameF[playerid], MAX_PLAYER_NAME);
        format(NameF[playerid], MAX_PLAYER_NAME, "%s[%d]", NameF[playerid], playerid);
    }
    return 1;
}

public OnPlayerConnect(playerid)
{
    GetPlayerName(playerid, NameF[playerid], MAX_PLAYER_NAME);
    format(NameF[playerid], MAX_PLAYER_NAME, "%s[%d]", NameF[playerid], playerid);
    return 1;
}

public OnPlayerText(playerid, text[])
{
    SetPlayerChatBubble(playerid,text,0xffff00FF,50.0,10000);
    if(strlen(text) >= MESSAGE_LENGTH)
    {
        new str[128], n = MESSAGE_LENGTH_START;
        for(;n <= MESSAGE_LENGTH; n++)if(text[n] == ' ')break;
        strmid(str, text, n+1, 128, 128);
        strdel(text, n, 128);

        format(text,128, "%s: {DEDEDE}%s", NameF[playerid], text);
        SendClientMessageToAll(n = GetPlayerColor(playerid), text);
       
        #if defined PERENOS_S_NICKOM
            format(str, 128, "%s: {DEDEDE}%s", NameF[playerid], str);
            SendClientMessageToAll(n, str);
        #else
            SendClientMessageToAll(0xDEDEDEFF, str);
        #endif
        return 0;
    }
    else
    {
        format(text, 128, "%s: {DEDEDE}%s", NameF[playerid], text);
        SendClientMessageToAll(GetPlayerColor(playerid), text);
        return 0;
    }
    //return 1;
}

#if defined PERENOS_S_NICKOM
    #undef PERENOS_S_NICKOM
#endif
#undef MESSAGE_LENGTH
#undef MESSAGE_LENGTH_START
Подправил.
Reply
#3

А разница? Буфера все-равно не хватит, чтобы длинный текст писать.
Reply
#4

Сложностей то сколько.
pawn Code:
define TO_BIG_LINE = (80)

public OnPlayerText(playerid, text[]) {
    if (strlen(text) >= TO_BIG_LINE) {
        new string[128],
            n = strfind(text, " ", true, TO_BIG_LINE);
        strmid(string, text, 0, n);
        strdel(text, 0, n);
        SendPlayerMessageToAll(playerid, string);
    }
    SendPlayerMessageToAll(playerid, text);
    return 0;
}
Reply
#5

Quote:
Originally Posted by Stepashka
View Post
Сложностей то сколько.
pawn Code:
define TO_BIG_LINE = (80)

public OnPlayerText(playerid, text[]) {
    if (strlen(text) >= TO_BIG_LINE) {
        new string[128],
            n = strfind(text, " ", true, TO_BIG_LINE);
        strmid(string, text, 0, n);
        strdel(text, 0, n);
        SendPlayerMessageToAll(playerid, string);
    }
    SendPlayerMessageToAll(playerid, text);
    return 0;
}
Принудительной отрезки нет. Заменю пробел символом "_" и всё в одной строке получится. причём получится может и так strmid(string, text, 0, -1);
Reply
#6

Quote:
Originally Posted by White_116
View Post
Принудительной отрезки нет. Заменю пробел символом "_" и всё в одной строке получится. причём получится может и так strmid(string, text, 0, -1);
согласен, упустил пару мелочей.
Reply
#7

PHP Code:
SendClientMessageEx(playerid, color, const string[]) 
{
    new 
scm1[100], scm2[100], scm3[100];
    if(
strlen(string) > 85)
    {
        
strmid(scm1, string, 0, 85);
        
strmid(scm2, string, 85, strlen(string));
    }
    if(
strlen(string) > 85){
    
format(scm3, 100, "%s ...", scm1);
    
SendClientMessage(playerid, color, scm3);
    
format(scm3, 100, "... %s", scm2);
    
SendClientMessage(playerid, color, scm3);}
    else return 
SendClientMessage(playerid, color, string);
    return 
false;
} 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)