open.mp forum
[Pawn] help about GameTextForPlayer - Printable Version

+ open.mp forum (https://forum.open.mp)
-- Forum: SA-MP (https://forum.open.mp/forumdisplay.php?fid=3)
--- Forum: Pawn Scripting (https://forum.open.mp/forumdisplay.php?fid=10)
--- Thread: [Pawn] help about GameTextForPlayer (/showthread.php?tid=2774)



help about GameTextForPlayer - LuvaDePedreiro - 2024-06-05

Hello everybody! I'm new to Pawn scripting, and I would like to know if there is a way to break the line using "\n" in the GameTextForPlayer function. I tried, but the text remains on the same line, if it's possible, what did I do wrong? Below is the line of code I'm using, I would be very grateful if someone could answer my question.

PHP Code:
GameTextForPlayer(playerid, "LINE ONE\nLINE TWO", 6000, 6); 


I searched the web, but I couldn't find anything similar, so I decided to ask here on the forum, sorry for the silly question.


RE: help about GameTextForPlayer - N0FeaR - 2024-06-07

GameTextForPlayer function does not support newline characters (\n) for creating multi-line texts. This is a limitation of the SA-MP text drawing functions. However, you can use the TextDraw system to achieve multi-line
Below is an example of how you can do this

PHP Code:
new Text:line1;
new 
Text:line2;

public 
OnGameModeInit() {
    line1 = TextDrawCreate(320.0, 240.0, "LINE ONE");
    TextDrawFont(line1, 1);
    TextDrawLetterSize(line1, 0.3, 1.2);
    TextDrawColor(line1, 0xFFFFFFFF);
    TextDrawSetOutline(line1, 1);

    line2 = TextDrawCreate(320.0, 255.0, "LINE TWO");
    TextDrawFont(line2, 1);
    TextDrawLetterSize(line2, 0.3, 1.2);
    TextDrawColor(line2, 0xFFFFFFFF);
    TextDrawSetOutline(line2, 1);
}

public 
OnPlayerConnect(playerid) {
    ShowPlayerGameText(playerid);
}

ShowPlayerGameText(playerid) {
    TextDrawShowForPlayer(playerid, line1);
    TextDrawShowForPlayer(playerid, line2);
} 



RE: help about GameTextForPlayer - LuvaDePedreiro - 2024-06-09

(2024-06-07, 11:03 AM)N0FeaR Wrote: GameTextForPlayer function does not support newline characters (\n) for creating multi-line texts. This is a limitation of the SA-MP text drawing functions. However, you can use the TextDraw system to achieve multi-line
Below is an example of how you can do this

PHP Code:
new Text:line1;
new 
Text:line2;

public 
OnGameModeInit() {
    line1 = TextDrawCreate(320.0, 240.0, "LINE ONE");
    TextDrawFont(line1, 1);
    TextDrawLetterSize(line1, 0.3, 1.2);
    TextDrawColor(line1, 0xFFFFFFFF);
    TextDrawSetOutline(line1, 1);

    line2 = TextDrawCreate(320.0, 255.0, "LINE TWO");
    TextDrawFont(line2, 1);
    TextDrawLetterSize(line2, 0.3, 1.2);
    TextDrawColor(line2, 0xFFFFFFFF);
    TextDrawSetOutline(line2, 1);
}

public 
OnPlayerConnect(playerid) {
    ShowPlayerGameText(playerid);
}

ShowPlayerGameText(playerid) {
    TextDrawShowForPlayer(playerid, line1);
    TextDrawShowForPlayer(playerid, line2);
} 

I found a solution, thanks for the answer.
I used it this way and it worked:

PHP Code:
GameTextForPlayer(playerid, "LINE ONE ~n~ LINE TWO", 3000, 4); 



RE: help about GameTextForPlayer - Mido - 2024-06-10

(2024-06-07, 11:03 AM)N0FeaR Wrote: GameTextForPlayer function does not support newline characters (\n) for creating multi-line texts. This is a limitation of the SA-MP text drawing functions. However, you can use the TextDraw system to achieve multi-line
Below is an example of how you can do this

PHP Code:
new Text:line1;
new 
Text:line2;

public 
OnGameModeInit() {
    line1 = TextDrawCreate(320.0, 240.0, "LINE ONE");
    TextDrawFont(line1, 1);
    TextDrawLetterSize(line1, 0.3, 1.2);
    TextDrawColor(line1, 0xFFFFFFFF);
    TextDrawSetOutline(line1, 1);

    line2 = TextDrawCreate(320.0, 255.0, "LINE TWO");
    TextDrawFont(line2, 1);
    TextDrawLetterSize(line2, 0.3, 1.2);
    TextDrawColor(line2, 0xFFFFFFFF);
    TextDrawSetOutline(line2, 1);
}

public 
OnPlayerConnect(playerid) {
    ShowPlayerGameText(playerid);
}

ShowPlayerGameText(playerid) {
    TextDrawShowForPlayer(playerid, line1);
    TextDrawShowForPlayer(playerid, line2);
} 
This seriously looks like a chatgpt generated response. If you actually read the docs you would have known that
PHP Code:
~n~ 
 means "new line".