String
#1

Hello everyone! I was thinking about something.
Is '\n' symbol for new line - a character ? i.e. I'm using a register system in a dialog which shows some info like username init:
pawn Код:
new string[164], playername[MAX_PLAYER_NAME];
format(string, sizeof(string), ""white"Blabla\n"red"Username: "white"%s\n"red"Enter your password:", playername);
ShowPlayerDialog(playerid,RegisterDialog,DIALOG_STYLE_INPUT,""white"Register:",string,"Register","Quit");GetPlayerName(playerid, playername, sizeof(playername));
Also the color name like: "white" and "red" .
Because I want to decrease the size of the string to 124 or maybe lower, but I am not sure are these things which I've asked about, being characters so I musn't change the string size.
Reply
#2

Yes, "\n" is for new line.Example: "New\nline".Will display:
Код:
New
line
OFF: Kukata the best
Reply
#3

Define the string globally, as ****** said, you only need to use 128 cells for strings, it's a pure waste to go over that size unless you're using it for dialogs! You can use that globally on whatever you'd like, by the way.
Reply
#4

\n Stands for new line.

if you made a Dialog box:

ShowPlayerDialog(playerid,1,DIALOG_STYLE_MSGBOX,"T est,"This is how\nIt works","Close","");

It would show a box with the message:

This is how
It works

You understand?
Reply
#5

Quote:
Originally Posted by Smokkr
Посмотреть сообщение
Yes, "\n" is for new line.Example: "New\nline".Will display:
Код:
New
line
OFF: Kukata the best
No, you didn't get my question. I didn't ask if is '\n' for new line, I know what is it for as '\t' is used to add tab. My question was is it being counted for a character in the string.

OFF: Ofcourse
Reply
#6

Quote:
Originally Posted by Sgt.TheDarkness
Посмотреть сообщение
Define the string globally, as ****** said, you only need to use 128 cells for strings, it's a pure waste to go over that size unless you're using it for dialogs! You can use that globally on whatever you'd like, by the way.
What if the text in the dialog is longer ? It will cut it off.
Reply
#7

All readable and non readable characters take 1 cell each character.
So a string like
Код:
\n\n\n
will take 4 slots, because 3 new line characters + null character.
It is technically called a null terminating string.

Код:
\tHello world!
13 characters + null character = 14 cells
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)