Formatting string question
#1

Hello, is it possible to do this without having to format string twice? It does work like this but not good enough for me after reading ******'s tutorial about cell spaces

pawn Код:
new string[128], string2[128];
format(string, sizeof(string), ""Pink"%s Banking", BankName(playerid)); // Dialog Header
format(string2, sizeof(string2), ""White"Your current account balance is "Green"$%d"White".", PlayerInfo[playerid][pBank]); // Dialog Content
ShowPlayerDialog(playerid, DIALOG_BALANCE, DIALOG_STYLE_MSGBOX, string, string2, "Close", ""); // Have to use two different strings.
You see where I had to make string and string2?
I cannot think of a way to only be able to format once.
Reply
#2

They're two different parameters so you will indeed need two variables. However, the maximum length for the header is 30 characters so you can reduce the array size for that one. The size for the second is roughly: 3 x 8 (colors) + 35 (text) + 11 (maximum integer length) = 70.

Tip: give your variables meaningful names. "header" and "bodytext" or something along those lines.
Reply
#3

Thanks Vince, +rep for the helpful information. Although I do have a little question..
Could you please explain to me exactly what I need to count in order to verify how many characters are used in each string? I thought it was just the words.
Reply
#4

Sorry for double post, I now understand max cash can be 11 but what about the strings? Like.. Most letters I have for bank name is Lloyds TSB (that's 9 characters) and how did you get 3 x 8 colours?
Reply


Forum Jump:


Users browsing this thread: