Need a solution for \t in dialogs. -
Kiets - 29.04.2012
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?
Re: Need a solution for \t in dialogs. -
Lorenc_ - 29.04.2012
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.
Re: Need a solution for \t in dialogs. -
Kiets - 29.04.2012
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.
Re: Need a solution for \t in dialogs. -
Finn - 29.04.2012
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.
Re: Need a solution for \t in dialogs. -
Danny1 - 29.04.2012
What does \t?Is that different then \n?
Re: Need a solution for \t in dialogs. -
IceCube! - 29.04.2012
\t is Tab its a giatn space
Re: Need a solution for \t in dialogs. -
Kiets - 29.04.2012
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.