pewpewpewpew
Известный
- 540
- 146
заменяй в convert_money_tagsВы купили Железная карта нац.банка у игрока * за $5 000 000 $500 000
почему то пишет двойную цену в чате
цена стоит 5.5кк (m 5 kk 500)
Вы купили Алмазный камень (928 шт.) у игрока * за VC$9,000,000 VC$280,000
Lua:
local function convert_money_tags(text)
if type(text) ~= "string" or text == "" then
return text
end
text = text:gsub(":M:%s*(%d+)%s*:KK:%s*(%d+)%s*:K:%s*([%d%.,]+)", function(m, kk, k)
return build_money(m, kk, k)
end)
text = text:gsub(":M:%s*(%d+)%s*:KK:%s*(%d+)", function(m, kk)
return build_money(m, kk, nil)
end)
text = text:gsub(":M:%s*(%d+)%s*:K:%s*([%d%.,]+)", function(m, k)
return build_money(m, nil, k)
end)
text = text:gsub(":KK:%s*(%d+)%s*:K:%s*([%d%.,]+)", function(kk, k)
return build_money(nil, kk, k)
end)
text = text:gsub(":M:%s*(%d+)", function(m)
return build_money(m, nil, nil)
end)
text = text:gsub(":KK:%s*(%d+)", function(kk)
return build_money(nil, kk, nil)
end)
text = text:gsub(":KV:%s*([%d%.,]+)", function(kv)
return build_vc_money(kv)
end)
text = text:gsub(":K:%s*([%d%.,]+)", function(k)
return build_money(nil, nil, k)
end)
text = merge_split_money_chunks(text)
return text
end
и добавь две хелп функции после build_vc_money
Lua:
local function parse_display_money(str)
str = tostring(str or "")
str = str:gsub("[%s%.,]", "")
return tonumber(str) or 0
end
local function merge_split_money_chunks(text)
if type(text) ~= "string" or text == "" then
return text
end
local changed = true
while changed do
changed = false
text = text:gsub("VC%$([%d%.,%s]+)%s+VC%$([%d%.,%s]+)", function(a, b)
local x, y = parse_display_money(a), parse_display_money(b)
if x > 0 and y > 0 then
changed = true
return "VC" .. format_money_styled(x + y)
end
end)
text = text:gsub("%$([%d%.,%s]+)%s+%$([%d%.,%s]+)", function(a, b)
local x, y = parse_display_money(a), parse_display_money(b)
if x > 0 and y > 0 then
changed = true
return format_money_styled(x + y)
end
end)
end
return text
end