New line (\n) in variable
#1

Hi, i have a problem creating a new line in a dialog (msg_box).

The text come from a variable.

pawn Код:
// Text from db:

// "Tu trabajo como Clнnico es fortalecer\n a otros jugadores ofreciendoles\n inyecciones con Adrenalina."

// Enum:
enum trabajos
{
        tId,
        tNombre_trabajo[28],
        tSkin,
        Float:tPos_x,
        Float:tPos_y,
        Float:tPos_z,
        tFuerza,
        tResistencia,
        tAstucia,
        tAgilidad,
        tInteligencia,
        tAyuda[300] // <===
};

// Loading dialog:

if(strfind(ayuda, lista_trabajos[i][tNombre_trabajo], true) != -1)
{
   ShowPlayerDialog(playerid, 1, DIALOG_STYLE_MSGBOX, "Ayuda", lista_trabajos[i][tAyuda], "Cerrar", "");
}

// Result:


Thx for your help and sorry for my bad english!
Reply
#2

That's because "\n" and '\n' aren't the same. The first one is a string consisting of two character: \ and n with ASCII values 92 and 110 respectively. The second is a single character constant with an ASCII value of 10 (LF, Line Feed). You need to delete those two characters and replace them with a single line feed char.
Reply
#3

Quote:
Originally Posted by Vince
Посмотреть сообщение
That's because "\n" and '\n' aren't the same. The first one is a string consisting of two character: \ and n with ASCII values 92 and 110 respectively. The second is a single character constant with an ASCII value of 10 (LF, Line Feed). You need to delete those two characters and replace them with a single line feed char.
Edit: I could solve it, i used this query

Код:
UPDATE `table_name` set `field` = REPLACE(`field`,'\\n', char(10))
Thx for your help!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)