diff options
Diffstat (limited to 'npc/functions/string.txt')
-rw-r--r-- | npc/functions/string.txt | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/npc/functions/string.txt b/npc/functions/string.txt index ef910961..7ee2562b 100644 --- a/npc/functions/string.txt +++ b/npc/functions/string.txt @@ -64,3 +64,30 @@ function script zfill { return .@str$; } + +// format_number( integer [, "separator"] ) +// +// formats a number properly according to the language of the player, +// or using the given separator +function script format_number { + .@number$ = str(getarg(0)); + .@len = getstrlen(.@number$); + .@separator$ = getarg(1, ","); + + if (getargcount() < 2 && playerattached()) + { + // get from user language + switch (Lang) + { + case 1: .@separator$ = " "; break; // French + default: .@separator$ = ","; // English (default) + } + } + + for (.@i = .@len - 3; .@i > 0; .@i -= 3) + { + .@number$ = insertchar(.@number$, .@separator$, .@i); + } + + return .@number$; +} |