Quantum is a Garry's Mod RPG framework.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
quantum/gamemode/engine/lib/sh_format.lua

32 lines
959 B

-- __ _ _______ _ __
-- / / /\ | | |__ __| | | \ \
-- / / / \ | |_ __ ___ | | ___ ___| |__ \ \
-- < < / /\ \ | | '_ ` _ \| |/ _ \/ __| '_ \ > >
-- \ \ / ____ \| | | | | | | | __/ (__| | | | / /
-- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/
Quantum.Format = {}
local function addMoneyVal( num )
return Quantum.Money.Prefix .. tostring( num ) .. Quantum.Money.Surfix
end
function Quantum.Format.Money( num )
if( num == nil ) then return addMoneyVal( 0 ) end
if( num >= 1e14 ) then
return addMoneyVal( num )
elseif( num <= -1e14 ) then
return addMoneyVal( "-" .. tostring( math.abs( num ) ) )
end
num = tostring( math.abs( num ) )
local sep = sep || ","
local dp = string.find( num, "%." ) || #num + 1
for i = dp - 4, 1, -3 do
num = num:sub( 1, i ) .. sep .. num:sub( i + 1 )
end
return ( negative && "-" || "" ) .. addMoneyVal( num )
end