New line (\n) in variable - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: New line (\n) in variable (
/showthread.php?tid=559728)
New line (\n) in variable -
Leon9741 - 24.01.2015
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!
Re: New line (\n) in variable -
Vince - 24.01.2015
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.
Respuesta: Re: New line (\n) in variable -
Leon9741 - 24.01.2015
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!