diff options
author | gumi <mekolat@users.noreply.github.com> | 2017-01-27 16:17:44 -0500 |
---|---|---|
committer | gumi <mekolat@users.noreply.github.com> | 2017-01-28 09:53:54 -0500 |
commit | 9cac9a4af2100aaf8eb6c171c015926c0c3fa376 (patch) | |
tree | 413e32320199035ad5f9a8f6ac373c381c4d634f /npc/functions/string.txt | |
parent | d939ac4a4974b5cb879aa43d931d79bbe80f25de (diff) | |
download | serverdata-9cac9a4af2100aaf8eb6c171c015926c0c3fa376.tar.gz serverdata-9cac9a4af2100aaf8eb6c171c015926c0c3fa376.tar.bz2 serverdata-9cac9a4af2100aaf8eb6c171c015926c0c3fa376.tar.xz serverdata-9cac9a4af2100aaf8eb6c171c015926c0c3fa376.zip |
add `format_number` function, make the banker use it
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$; +} |