Need a solution for \t in dialogs.
#1

Hi all.
I have in my server some dialogs which are formatted with \t and there is one thing. There are different lengths of all words so sometimes my dialog is fucked up. I don't know how to explain because i am not english so here i show you a screenshot.

Every line is made like this: "[playername]\t\t[level]\t[activity]".
I hope you understand me and i am asking how can i fix this, is there any way to check those words before formatting the dialog or something like that when i could know how many \t's i have to use?
Reply
#2

You should format the reversed way; "[activity]\t[level]\t[name]"

It's doing this because a name could be three tabs big (12 characters), and if you are tabbing it twice, it'll be 18 characters. Hard to explain but yeah, do it reversed.
Reply
#3

Hm yeah this is logical to put the name at the end. I think i will make it if there is no other solution. Thanks.
Reply
#4

There's a sweet feature in the format function regarding strings, if you put a value between '%' and 's', it basically fills in the empty slots with spaces (' ').

Examples:
pawn Код:
print("%10s", "test");
// This will print "test      "

print("%20s", "test");
// This will print "test                "

print("%30s", "test");
// This will print "test                          "

print("%40s", "test");
// This will print "test                                    "

print("%50s", "test");
// This will print "test                                              "
Format your dialog strings this way:
pawn Код:
// 24 is the max player name lenght
format(string, sizeof(string), "%24s\t%d\t%s", name, level, activity);
I haven't tested this so I'm not sure if it works like you want, but just wanted to let you know about this feature.
Reply
#5

What does \t?Is that different then \n?
Reply
#6

\t is Tab its a giatn space
Reply
#7

Quote:
Originally Posted by Finn
Посмотреть сообщение
There's a sweet feature in the format function regarding strings, if you put a value between '%' and 's', it basically fills in the empty slots with spaces (' ').

Examples:
pawn Код:
print("%10s", "test");
// This will print "test      "

print("%20s", "test");
// This will print "test                "

print("%30s", "test");
// This will print "test                          "

print("%40s", "test");
// This will print "test                                    "

print("%50s", "test");
// This will print "test                                              "
Format your dialog strings this way:
pawn Код:
// 24 is the max player name lenght
format(string, sizeof(string), "%24s\t%d\t%s", name, level, activity);
I haven't tested this so I'm not sure if it works like you want, but just wanted to let you know about this feature.
Man, this thing is really sweet and it works, i was thinking how to make it for some months and didn't even think about it, dumbass i am. Anyway, thank you a lot.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)