04.09.2010, 21:18
* AddLineBreaks(input[], chars=80)
This function is meant to be used by DIALOG_STYLE_MSGBOX dialogs, when it is desired to show a large string, and this string to be split into several lines. It adds the line breaks just if it finds a ' ' (space) character.
- Parameters:
-- input[]: The string to be split.
-- chars[]: How many minimum characters should show per line (default: 80).
- Returns:
-- The formatted string.
This function is meant to be used by DIALOG_STYLE_MSGBOX dialogs, when it is desired to show a large string, and this string to be split into several lines. It adds the line breaks just if it finds a ' ' (space) character.
- Parameters:
-- input[]: The string to be split.
-- chars[]: How many minimum characters should show per line (default: 80).
- Returns:
-- The formatted string.
pawn Code:
AddLineBreaks(input[], chars=80)
{
new output[512];
format(output, sizeof(output), "%s", input);
for(new i, j, o = strlen(output); i < o; i++, j++)
{
if(j >= chars && output[i] == ' ')
{
output[i] = '\n';
j = 0;
}
}
return output;
}