Seviel
28.03.2019, 17:36
Название:
auto_new_line
Описание:
Проставляет \n по возможности на ближайшем пробеле.
Аргументы:
string - Массив со строкой в которой будет проставляться переходы
lenght_line - Количество символов в одной строке, по умолчанию 70
string_size - Размер строки, по умолчанию количество равно sizeof string
Код:
stock auto_new_line(string[], const lenght_line = 70, const string_size = sizeof string)
{
new
point = 0,
len = strlen(string),
check = 0;
while(point < len - lenght_line)
{
for(new j = point; j < point + lenght_line; ++j)
{
if(string[j] == '\n')
{
check = 1;
point = j + 1;
break;
}
}
if(check == 0)
{
for(new j = point + lenght_line; j >= 0; --j)
{
if(string[j] == ' ')
{
string[j] = '\n';
check = 1;
point = j;
break;
}
}
}
if(check == 0)
{
strins(string, "\n", point + lenght_line, string_size);
point = point + lenght_line + 1;
}
check = 0;
}
return 1;
}
Пример:
public OnPlayerSpawn(playerid)
{
new string[450] = "\
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod \
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, \
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. \
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu \
fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in \
culpa qui officia deserunt mollit anim id est laborum.\
";
auto_new_line(string, 70);
ShowPlayerDialog(playerid, 0, DIALOG_STYLE_MSGBOX, "Lorem ipsum", string, "Ok", "");
return 0;
}
https://pasteboard.co/I7vZkLz.png
https://pasteboard.co/I7vZkLz.png
Автор: knox
auto_new_line
Описание:
Проставляет \n по возможности на ближайшем пробеле.
Аргументы:
string - Массив со строкой в которой будет проставляться переходы
lenght_line - Количество символов в одной строке, по умолчанию 70
string_size - Размер строки, по умолчанию количество равно sizeof string
Код:
stock auto_new_line(string[], const lenght_line = 70, const string_size = sizeof string)
{
new
point = 0,
len = strlen(string),
check = 0;
while(point < len - lenght_line)
{
for(new j = point; j < point + lenght_line; ++j)
{
if(string[j] == '\n')
{
check = 1;
point = j + 1;
break;
}
}
if(check == 0)
{
for(new j = point + lenght_line; j >= 0; --j)
{
if(string[j] == ' ')
{
string[j] = '\n';
check = 1;
point = j;
break;
}
}
}
if(check == 0)
{
strins(string, "\n", point + lenght_line, string_size);
point = point + lenght_line + 1;
}
check = 0;
}
return 1;
}
Пример:
public OnPlayerSpawn(playerid)
{
new string[450] = "\
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod \
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, \
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. \
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu \
fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in \
culpa qui officia deserunt mollit anim id est laborum.\
";
auto_new_line(string, 70);
ShowPlayerDialog(playerid, 0, DIALOG_STYLE_MSGBOX, "Lorem ipsum", string, "Ok", "");
return 0;
}
https://pasteboard.co/I7vZkLz.png
https://pasteboard.co/I7vZkLz.png
Автор: knox